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 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) {