NETWORK_ERROR: XMLHttpRequest Exception 101

后端 未结 7 1970
南旧
南旧 2020-11-30 07:45

I am getting this Error

NETWORK_ERROR: XMLHttpRequest Exception 101

when trying to get XML content from one site.

Here

相关标签:
7条回答
  • 2020-11-30 07:53

    Another modern method of solving this problem is Cross Origin Ressource Sharing. HTML5 offers this feature. You can "wrap" your XMLhttp request in this CORS_request and if the target browser supports this feature, you can use it and wont have no problems.

    EDIT: Additionaly i have to add that there are many reasons which can cause this Issue. Not only a Cross Domain Restriction but also simply wrong Settings in your WEB.CONFIG of your Webservice.

    Example IIS(.NET):

    To enable HTTP access from external sources ( in my case a compiled Phonegap app with CORS request ) you have to add this to your WEB.CONFIG

        <webServices>
            <protocols>
                <add name="HttpGet"/>
                <add name="HttpPost"/>
            </protocols>
        </webServices>
    

    Another scenario:

    I got two webservices running... One on Port 80 and one on Port 90. This also gave me an XML HTTP Request Error. I even dont know why :). Nevertheless i think this can help many not well experienced readers.

    0 讨论(0)
  • 2020-11-30 08:04

    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.

    0 讨论(0)
  • 2020-11-30 08:05
    xmlhttp.open("GET",url, true);
    

    set the async part to true

    0 讨论(0)
  • 2020-11-30 08:05

    I found a very nice article with 2 diferent solutions.

    1. The first one implementing jQuery and JSONP, explaining how simple it is.
    2. The second approach, it's redirecting trough a PHP call. Very simple and very nice.

    http://mayten.com.ar/blog/42-ajax-cross-domain

    0 讨论(0)
  • 2020-11-30 08:06

    Request aborted because it was cached or previously requested? It seems the XMLHttpRequest Exception 101 error can be thrown for several reasons. I've found that it occurs when I send an XMLHttpRequest with the same URL more than one time. (Changing the URL by appending a cache defeating nonsense string to the end of the URL allows the request to be repeated. -- I wasn't intending to repeat the request, but events in the program caused it to happen and resulted in this exception).

    Not returning the correct responseText or responseXML in the event of a repeated request is a bug (probably webKit).

    When this exception occurred, I did get an onload event with readyState==4 and the request object state=0 and responseText=="" and responseXML==null. This was a cross domain request, which the server permits.

    This was on an Android 2.3.5 system which uses webKit/533.1

    Anyone have documentation on what the exception is supposed to mean?

    0 讨论(0)
  • 2020-11-30 08:07

    The restriction that you cannot access data from another server with a XMLHttpRequest can apply even if the url just implies a remote server.

    So: url = "http://www.myserver.com/webpage.html"

    may fail,

    but: url = "/webpage.html"

    succeed - even if the request is being made from www.myserver.com

    0 讨论(0)
提交回复
热议问题