Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
643 views
in Technique[技术] by (71.8m points)

ajax - NETWORK_ERROR: XMLHttpRequest Exception 101

I am getting this Error

NETWORK_ERROR: XMLHttpRequest Exception 101

when trying to get XML content from one site.

Here is my code:

    var xmlhttp; 
    if(window.XMLHttpRequest) { 
        xmlhttp = new XMLHttpRequest();
    }

    if (xmlhttp==null) {
        alert ("Your browser does not support XMLHTTP!");
        return;
    }

    xmlhttp.onReadyStateChange=function() {
        if(xmlhttp.readyState==4) {
            var value =xmlhttp.responseXML;
            alert(value);
        }
    }
    xmlhttp.open("GET",url,false);
    xmlhttp.send();
    //alert(xmlhttp.responseXML);
}

xmlhttp.open("GET",url,false);
xmlhttp.send(null);

Does any one have a solution?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If the url you provide is located externally to your server, and the server has not allowed you to send requests, you have permission problems. You cannot access data from another server with a XMLHttpRequest, without the server explicitly allowing you to do so.

Update: Realizing this is now visible as an answer on Google, I tried to find some documentation on this error. That was surprisingly hard.

This article though, has some background info and steps to resolve. Specifically, it mentions this error here:

As long as the server is configured to allow requests from your web application's origin, XMLHttpRequest will work. Otherwise, an INVALID_ACCESS_ERR exception is thrown

An interpretation of INVALID_ACCESS_ERR seems to be what we're looking at here.

To solve this, the server that receives the request, must be configured to allow the origin. This is described in more details at Mozilla.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...