Skip to content

Commit

Permalink
Ajax: Don't let onreadystatechange preempt exceptions from xhr.send
Browse files Browse the repository at this point in the history
  • Loading branch information
gibson042 committed Oct 23, 2015
1 parent 3680689 commit b5c6fc7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/ajax/xhr.js
Expand Up @@ -174,8 +174,12 @@ if ( xhrSupported ) {
callback(); callback();
} else { } else {


// Add to the list of active xhr callbacks // Register the callback, but delay it in case `xhr.send` throws
xhr.onreadystatechange = callback; xhr.onreadystatechange = function() {
if ( callback ) {
window.setTimeout( callback );
}
};


xhr.send( ( options.hasContent && options.data ) || null ); xhr.send( ( options.hasContent && options.data ) || null );
} }
Expand Down

0 comments on commit b5c6fc7

Please sign in to comment.