I tried using the timeout option on $.ajax and it just didn't seem to
work.
I think I tracked it down, since xhr gets set to null in
onreadystatechange( "timeout" );,
if ( xhr ) xhr.abort(); never runs and therefor the ajax call never
gets cancelled. Is this a bug or is it how it is meant to work?
It works (closes the connection) if you move xhr.abort(); before
running onreadystatechange.
Line: 3486
if ( s.async ) {
// don't attach the handler to the request, just poll it instead
var ival = setInterval(onreadystatechange, 13);
// Timeout checker
if ( s.timeout > 0 )
setTimeout(function(){
// Check to see if the request is still happening
if ( xhr ) {
if( !requestDone )
onreadystatechange( "timeout" );
// Cancel the request
if ( xhr )
xhr.abort();
}
}, s.timeout);
}