]> source.dussan.org Git - jquery.git/commitdiff
Ajax: Don't let onreadystatechange preempt exceptions from xhr.send
authorRichard Gibson <richard.gibson@gmail.com>
Fri, 23 Oct 2015 16:42:40 +0000 (12:42 -0400)
committerRichard Gibson <richard.gibson@gmail.com>
Fri, 23 Oct 2015 16:44:48 +0000 (12:44 -0400)
Ref 0a6e1c4b191f177fce2dac5fd3a17b76f853fd26

src/ajax/xhr.js

index b62417138919c5e26eabd7c36d3d20fb361ee83f..5e34d38127011563e095816ef6be3bccea3492ce 100644 (file)
@@ -174,8 +174,12 @@ if ( xhrSupported ) {
                                                callback();
                                        } else {
 
-                                               // Add to the list of active xhr callbacks
-                                               xhr.onreadystatechange = callback;
+                                               // Register the callback, but delay it in case `xhr.send` throws
+                                               xhr.onreadystatechange = function() {
+                                                       if ( callback ) {
+                                                               window.setTimeout( callback );
+                                                       }
+                                               };
 
                                                xhr.send( ( options.hasContent && options.data ) || null );
                                        }