Permalink
Browse files

Ajax: Don't let onreadystatechange preempt exceptions from xhr.send

  • Loading branch information...
gibson042 committed Oct 23, 2015
1 parent 3680689 commit b5c6fc7ebb3ad83e174211b7858983a8652a774a
Showing with 6 additions and 2 deletions.
  1. +6 −2 src/ajax/xhr.js
View
@@ -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 );
}

0 comments on commit b5c6fc7

Please sign in to comment.