stm32 web ajax,STM32的WEB服务器怎么返回AJAX的JSON数据格式的?求教!
做了个 定时访问的 数据的页面 AJAX的 ,不会有刷新的感觉handler();var xhr = false;function myrefresh(){try{xhr = new ActiveXObject("Msxml2.XMLHTTP");}catch (e){try{xhr = new ActiveXObject("Microsoft.XMLHTTP");}catch(E){xhr ..
做了个 定时访问的 数据的页面 AJAX的 ,不会有刷新的感觉
handler();
var xhr = false;
function myrefresh()
{
try
{
xhr = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(E)
{
xhr = false;
}
}
if (!xhr && typeof XMLHttpRequest != 'undefined')
{
xhr = new XMLHttpRequest();
}
xhr.onreadystatechange = handler;
xhr.open("GET","http://192.168.1.13",true);
xhr.send(null);
}
function handler()
{
if(xhr==null)
return;
if(xhr.readyState == 4)
{
if(xhr.status == 200 ||xhr.status == 0)
{
var data = eval("("+xhr.responseText+")");
document.getElementById("type").value = data.type;
document.getElementById("ip").value = data.ip;
document.getElementById("port").value = data.port;
}
}
}
setInterval('myrefresh()',8000); //指定1秒刷新一次
我板子设置的IP地址是192.168.1.13
我返回
HTTP/1.1 200 OK\r\n Content-type: text/xml\r\n\r\n
{type:2,ip:"192.168.2.3",port:8058}
没有反应 没这个方面的基础 求教!
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐



所有评论(0)