SCRIPT7002: XMLHttpRequest: Network Error 0x2ef3,

2019-01-01 04:34发布

问题:

I keep receiving this error when I do some Ajax calls...

It may even be something to do with Geocoding but I really have no idea how to capture the error to display something useful to users... or even how to solve the problem as it seems to just be referencing some kind of pointer or something :S 0x2ef3

SCRIPT7002: XMLHttpRequest: Network Error 0x2ef3, Could not complete the operation due to error 00002ef3.

An image might be more helpful than the error message:

\"enter

Any ideas at all?

My code fires off 10 ajax calls in 1 second to be processed by geocoding server side.

The error comes up intermittently. Sometimes I get geocoded results and sometimes I get that error. I would say I get it 10% of the time. It completely stops the ajax call from firing my error handler in jQuery.

回答1:

This is the fix that worked for me. There is invalid mime or bad characterset being sent with your json data causing that errror. Add the charset like this to help it from getting confused:

$.ajax({
  url:url,
  type:\"POST\",
  data:data,
  contentType:\"application/json; charset=utf-8\",
  dataType:\"json\",
  success: function(){
  ...
  }
});

Reference:

Jquery - How to make $.post() use contentType=application/json?

Could not complete the operation due to error c00ce56e



回答2:

We also encountered similar problems. However, setting the charset as noted in the previous comment did not help. Our application was making an AJAX request every 60 seconds and our webserver, nginx, was sending Keep-Alive timeout at 60 seconds.

We fixed the problem by setting the keep-alive timeout value to 75 seconds.

This is what we believe was happening:

  1. IE makes an AJAX request every 60 seconds, setting Keep-Alive in the request.
  2. At the same time, nginx knows that the Keep-Alive timeout value is ignored by IE, so it starts the TCP connection close process (in the case of FF/Chrome this is started by the client)
  3. IE receives the close connection request for the previously sent request. Since this is not expected by IE, it throws an error and aborts.
  4. nginx still seems to be responding to the request even though the connection is closed.

A Wireshark TCP dump would provide more clarity, our problem is fixed and we do not wish to spend more time on it.



回答3:

I received the same error (SCRIPT7002: XMLHttpRequest: Network Error 0x80004004, Operation aborted), in our case it was because of JavaScript\'s same origin policy.

Our web app was making a JQuery AJAX call to our server on Port 8080. The call was getting intercepted and re-routed over SSL (due to server rules mandating that incoming traffic use SSL).

Once we made our web app load through the SSL port the issue was fixed.



回答4:

I had this problem, a an AJAX Post request that returned some JSON would fail, eventually returning abort, with the:

SCRIPT7002: XMLHttpRequest: Network Error 0x2ef3

error in the console. On other browsers (Chrome, Firefox, Safari) the exact same AJAX request was fine.

Tracked my issue down - investigation revealed that the response was missing the status code. In this case it should have been 500 internal error. This was being generated as part of a C# web application using service stack that requires an error code to be explicitly set.

IE seemed to leave the connection open to the server, eventually it timed out and it \'aborted\' the request; despite receiving the content and other headers.

Perhaps there is an issue with how IE is handling the headers in posts.

Updating the web application to correctly return the status code fixed the issue.

Hope this helps someone!



回答5:

This issue happened in my project because of an ajax GET call with a long xml string as a parameter value. Solved by the following approach: Making it as ajax post call to Java Spring MVC controller class method like this.

$.ajax({
    url: \"controller_Method_Name.html?variable_name=\"+variable_value,
    type: \"POST\",
    data:{ 
            \"xmlMetaData\": xmlMetaData // This variable contains a long xml string
    },
    success: function(response)
    {
        console.log(response);
    }
  });

Inside Spring MVC Controller class method:

@RequestMapping(value=\"/controller_Method_Name\")
  public void controller_Method_Name(@RequestParam(\"xmlMetaData\") String metaDataXML, HttpServletRequest request)
{
   System.out.println(metaDataXML);
}


回答6:

I had this error for some time and found a fix. This fix is for Asp.net application, Strange it failed only in IE non compatibility mode, but works in Firefox and Crome. Giving access to the webservice service folder for all/specific users solved the issue.

Add the following code in web.config file:

 <location path=\"YourWebserviceFolder\">
  <system.web>
   <authorization>
    <allow users=\"*\"/>
   </authorization>
  </system.web>
 </location>


回答7:

I have stumbled across this questions and answers after receiving the aforementioned error in IE11 when trying to upload files using XMLHttpRequest:

var reqObj = new XMLHttpRequest();

//event Handler
reqObj.upload.addEventListener(\"progress\", uploadProgress, false);
reqObj.addEventListener(\"load\", uploadComplete, false);
reqObj.addEventListener(\"error\", uploadFailed, false);
reqObj.addEventListener(\"abort\", uploadCanceled, false);

//open the object and set method of call (post), url to call, isAsynchronous(true)
reqObj.open(\"POST\", $rootUrlService.rootUrl + \"Controller/UploadFiles\", true);

//set Content-Type at request header.for file upload it\'s value must be multipart/form-data
reqObj.setRequestHeader(\"Content-Type\", \"multipart/form-data\");

//Set header properties : file name and project milestone id
reqObj.setRequestHeader(\'X-File-Name\', name);

// send the file
// this is the line where the error occurs
reqObj.send(fileToUpload);

Removing the line reqObj.setRequestHeader(\"Content-Type\", \"multipart/form-data\"); fixed the problem.

Note: this error is shown very differently in other browsers. I.e. Chrome shows something similar to a connection reset which is similar to what Fiddler reports (an empty response due to sudden connection close).

Also, this error appeared only when upload was done from a machine different from WebServer (no problems on localhost).



回答8:

I just want to add what solved this problem for me, as it is different to all of the above answers.

The ajax calls that were causing the problem were trying to pass an empty data object. It seems IE does not like this, but other browsers don\'t mind.

To fix it I simply removed data: {}, from the ajax call.



回答9:

With the Apache 2 change KeepAliveTimeout set it to 60 or above



回答10:

Upping the directive in the virtualhost for KeepAliveTimeout to 60 solved this for me.



回答11:

Have encountered the same issue in my asp.net project, in the end i found the issue is with the target function not static, the issue fixed after I put the keyword static.

[WebMethod]
public static List<string> getRawData()


回答12:

Incase none of these solutions were \"clear\" enough, essentially IE/Edge is failing to parse your \"data\" field of your AJAX call properly. More than likely you\'re sending an \"encoded\" JSON object.

What Failed: \"data\": \"{\\\"Key\\\":\\\"Value\\\"}\",

What Works: \"data\":\'{\"Key\":\"Value\"}\'



回答13:

[SOLVED]

I only observed this error today. for me the Error code was different though.

SCRIPT7002: XMLHttpRequest: Network Error 0x2efd, Could not complete the operation due to error 00002efd.

It was occurring randomly and not all time. but what it noticed is, if it comes it comes for subsequent ajax calls.. so i put some delay of 5 seconds between the ajax calls and it resolved.



标签: jquery ajax