Internet explorer (only) aborts AJAX posts intermittently

Trentj picture Trentj · Jul 23, 2013 · Viewed 7.6k times · Source

Over a week pulling my hair out.

Using:

Jquery 1.9.1

malsup form plugin using similar to JSON example: http://malsup.com/jquery/form/#json

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" /> with of without same error

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

Internet explorer (8/9/10) will randomly aborts AJAX POST requests (very randomly)

By Abort, I mean, NOTHING is sent over http "at all" - it just aborts then puts tears in my eyes.

F12 Developer tools under network reads:

URL my url which is correct

Result (Aborted) it literally reads (Aborted)

Type blank - literally nothing in here

Received 0B

Taken 202ms

Initiator (Pending) it literally reads (Pending)

Opening capture of the Request:

Requestion header are empty

Requestion body are empty

eveything is empty

However under Timings tab, I notice that it says in order Wait Start Start Gap DOMContentLoaded (event) Load (Event)

Should start be there twice?? or am I somehow submitting the request twice and this is cause the abort.

I will say, successful POSTS have Start twice under the timings tab.

I also console.log errors and get:

xmlhttprequest.ReadyState 4

xmlhttprequest.Status: 12019

This When I click submit a second time it works. Customers won't like this...

$('#formId').ajaxForm( {
    dataType :  'json',
    cache:      false,
    beforeSend: beforeGenericPostForm,
    success :   FormResponse,
    error:      genericError
});

$('#formSubmitId').click(function(e){
    e.preventDefault();

    //perform some custom simple form validation - return false if problem

    $('#formId').submit();
});

So genericError gets called and gives me error messages above.

I can console.log up until end of beforeSend: beforeGenericPostForm, function, then it dies/aborts.

This is something I have been searching for ages now and cannot find a resolve.

My form is standard HTML form and I post application/x-www-form-urlencoded and receive JSON from server with headers application/json; charset=utf-8

Does anyone have any clues or similar issues?

Or is this just a standard bug as posted below and if so, how do you get around it?

http://bugs.jquery.com/ticket/9352

Many thanks if you have any advice, holding of from a years development on launching because of this now.

Answer

Sparkm4n picture Sparkm4n · Jul 11, 2019

I used to have similar issue and what I found out so far was the timing out problem in Internet Explorer, In my code I defined following handler as empty

xdr.onprogress = function () { };
xdr.ontimeout = function () { };
xdr.onerror = function () { }; 

and wrapped the send function in a timeout declaration

setTimeout(function () {
     xdr.send();
 }, 0);

that solved my issue. Hope this helps