我制作了一个简单的脚本来显示来自路由器的数据,但是有一个错误:
无法加载资源
但位置可用。那么问题的真正原因可能是什么。
var xmlhttp = null;
if ( window.ActiveXObject )
{
xmlhttp = new ActiveXObject ( "Microsoft.XMLHTTP" );
}
else
{
xmlhttp = new XMLHttpRequest();
}
xmlhttp.open ( "POST", "http://" + routerIP + port + link, true );
xmlhttp.setRequestHeader ( "Content-type", "application/x-www-form-urlencoded" );
//base64UserPass in format user:pass
xmlhttp.setRequestHeader ( "Authorization", "Basic " + base64UserPass );
xmlhttp.setRequestHeader ( "Connection", "close" );
xmlhttp.onreadystatechange = function()
{
if ( xmlhttp.readyState == 4 )
{
document.write ( xmlhttp.responseText );
}
else
{
alert ( "Error ocurred: server not responding!\n" + xmlhttp.responseText );
}
};
xmlhttp.send ( "" );