aboutsummaryrefslogtreecommitdiffstats
path: root/src/ajax
diff options
context:
space:
mode:
authorRichard Gibson <richard.gibson@gmail.com>2015-10-23 11:35:11 -0400
committerRichard Gibson <richard.gibson@gmail.com>2015-10-23 11:35:11 -0400
commit0a6e1c4b191f177fce2dac5fd3a17b76f853fd26 (patch)
tree404f91a028347f0a98a942fee9247b099d6962f2 /src/ajax
parentc40b12a6bd30649066babc6f8c16b53a14b110dd (diff)
downloadjquery-0a6e1c4b191f177fce2dac5fd3a17b76f853fd26.tar.gz
jquery-0a6e1c4b191f177fce2dac5fd3a17b76f853fd26.zip
Ajax: Catch synchronous readystatechange events
Fixes gh-2673 Ref trac-14683
Diffstat (limited to 'src/ajax')
-rw-r--r--src/ajax/xhr.js14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/ajax/xhr.js b/src/ajax/xhr.js
index 313f24a04..b62417138 100644
--- a/src/ajax/xhr.js
+++ b/src/ajax/xhr.js
@@ -105,11 +105,6 @@ if ( xhrSupported ) {
}
}
- // Do send the request
- // This may raise an exception which is actually
- // handled in jQuery.ajax (so no try/catch here)
- xhr.send( ( options.hasContent && options.data ) || null );
-
// Listener
callback = function( _, isAbort ) {
var status, statusText, responses;
@@ -168,14 +163,21 @@ if ( xhrSupported ) {
}
};
+ // Do send the request
+ // `xhr.send` may raise an exception, but it will be
+ // handled in jQuery.ajax (so no try/catch here)
if ( !options.async ) {
- // if we're in sync mode we fire the callback
+ xhr.send( ( options.hasContent && options.data ) || null );
+
+ // If we're in sync mode we fire the callback
callback();
} else {
// Add to the list of active xhr callbacks
xhr.onreadystatechange = callback;
+
+ xhr.send( ( options.hasContent && options.data ) || null );
}
},