登录路由器



我做了一个简单的脚本显示数据从路由器,但有一个错误:

加载资源失败

但是位置是可用的。那么问题的真正原因是什么呢?

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 ( "" );

出于安全原因,您不能使用AJAX与不同的域进行交互。

jQuery也支持ACD (AJAX跨域)。查看http://api.jquery.com/jQuery.ajax/(设置"crossDomain")

最新更新