做了个 定时访问的 数据的页面 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}
没有反应 没这个方面的基础 求教!