From c0abb69449d1237fa9c15ced83196341738514f0 Mon Sep 17 00:00:00 2001 From: Bruno Abrantes Date: Mon, 23 Jul 2012 12:20:47 +0100 Subject: [PATCH 1/2] Pass status and XHR to the success and complete handlers --- src/reqwest.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/reqwest.js b/src/reqwest.js index 1787c9b..db36a76 100644 --- a/src/reqwest.js +++ b/src/reqwest.js @@ -176,7 +176,8 @@ } function success(resp) { - var r = resp.responseText + var r = resp.responseText, + xhr = resp if (r) { switch (type) { case 'json': @@ -198,10 +199,10 @@ } } - fn(resp) - o.success && o.success(resp) + fn(resp, xhr.status, xhr) + o.success && o.success(resp, xhr.status, xhr) - complete(resp) + complete(resp, xhr.status, xhr) } function error(resp, msg, t) { From 86f2b3559b71eb3bb124a24a24384f131e193b00 Mon Sep 17 00:00:00 2001 From: Bruno Abrantes Date: Fri, 14 Sep 2012 17:55:57 +0200 Subject: [PATCH 2/2] remove old IE JSONP handling hack --- reqwest.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/reqwest.js b/reqwest.js index 8799968..7d73d52 100644 --- a/reqwest.js +++ b/reqwest.js @@ -99,20 +99,12 @@ script.type = 'text/javascript' script.src = url script.async = true - if (typeof script.onreadystatechange !== 'undefined') { - // need this for IE due to out-of-order onreadystatechange(), binding script - // execution to an event listener gives us control over when the script - // is executed. See http://jaubourg.net/2010/07/loading-script-as-onclick-handler-of.html - script.event = 'onclick' - script.htmlFor = script.id = '_reqwest_' + reqId - } script.onload = script.onreadystatechange = function () { if ((script[readyState] && script[readyState] !== 'complete' && script[readyState] !== 'loaded') || loaded) { return false } script.onload = script.onreadystatechange = null - script.onclick && script.onclick() // Call the user callback with the last value stored and clean up values and scripts. o.success && o.success(lastValue) lastValue = undefined