Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Internet explorer (only) aborts AJAX posts intermittently

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.

like image 731
Trentj Avatar asked Jul 23 '13 12:07

Trentj


1 Answers

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

like image 178
Sparkm4n Avatar answered Sep 24 '22 02:09

Sparkm4n