From e5067154173a4170fcb4e1b03bcd1680db1dff22 Mon Sep 17 00:00:00 2001 From: Alex Hutton Date: Tue, 4 Nov 2014 15:15:51 +1100 Subject: [PATCH 1/2] whitespace --- jquery.iecors.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jquery.iecors.js b/jquery.iecors.js index 3c9d418..5715a3c 100755 --- a/jquery.iecors.js +++ b/jquery.iecors.js @@ -23,12 +23,12 @@ var headers = { 'Content-Type': xdr.contentType }; complete(200, 'OK', { text: xdr.responseText }, headers); }; - + // Apply custom fields if provided - if ( s.xhrFields ) { + if ( s.xhrFields ) { xhr.onerror = s.xhrFields.error; xhr.ontimeout = s.xhrFields.timeout; - } + } xdr.open( s.type, s.url ); From 2cdae70962833e399c9581a42bd78843b0fc4814 Mon Sep 17 00:00:00 2001 From: Alex Hutton Date: Tue, 4 Nov 2014 15:23:36 +1100 Subject: [PATCH 2/2] Fix custom fields application xhr was not in scope. xdr was intended. This is fixed. Using $.extend() means we do not have to specify each field. Renamed xhrFields to xdrFields. As this is what they are. Fomerly, property names were unnecessarily translated: xhrFields.error -> xhr.onerror xhrFields.timeout -> xhr.ontimeout Now there is no translation, use the exact names: xdrFields.onerror -> xdr.onerror xdrFields.ontimeout -> xdr.ontimeout --- jquery.iecors.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/jquery.iecors.js b/jquery.iecors.js index 5715a3c..9bd3554 100755 --- a/jquery.iecors.js +++ b/jquery.iecors.js @@ -25,9 +25,8 @@ }; // Apply custom fields if provided - if ( s.xhrFields ) { - xhr.onerror = s.xhrFields.error; - xhr.ontimeout = s.xhrFields.timeout; + if ( s.xdrFields ) { + $.extend(xdr, s.xdrFields); } xdr.open( s.type, s.url );