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 = 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}

没有反应  没这个方面的基础  求教!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值