From b5c6fc7ebb3ad83e174211b7858983a8652a774a Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Fri, 23 Oct 2015 12:42:40 -0400 Subject: [PATCH] Ajax: Don't let onreadystatechange preempt exceptions from xhr.send Ref 0a6e1c4b191f177fce2dac5fd3a17b76f853fd26 --- src/ajax/xhr.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ajax/xhr.js b/src/ajax/xhr.js index b62417138..5e34d3812 100644 --- a/src/ajax/xhr.js +++ b/src/ajax/xhr.js @@ -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 ); } -- 2.39.5