diff options
author | malsup <malsup@gmail.com> | 2010-04-29 11:45:34 +0800 |
---|---|---|
committer | John Resig <jeresig@gmail.com> | 2010-06-15 11:02:26 +0800 |
commit | d1931a8241dcac1617cc8388f6dd6284c89c545d (patch) | |
tree | 4743b31203e0e0e2670fde93dbe31a99a2f14cce /src/ajax.js | |
parent | 1533bf7c7794d8e078e7ce5e36de6d190651540a (diff) | |
download | jquery-d1931a8241dcac1617cc8388f6dd6284c89c545d.tar.gz jquery-d1931a8241dcac1617cc8388f6dd6284c89c545d.zip |
Fix for http://dev.jquery.com/ticket/6451
Diffstat (limited to 'src/ajax.js')
-rw-r--r-- | src/ajax.js | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/ajax.js b/src/ajax.js index 7cf280ab3..ffd870c28 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -237,17 +237,24 @@ jQuery.extend({ s.dataType = "script"; // Handle JSONP-style loading - window[ jsonp ] = window[ jsonp ] || function( tmp ) { + var customJsonp = window[ jsonp ]; + window[ jsonp ] = function( tmp ) { data = tmp; jQuery.ajax.handleSuccess( s, xhr, status, data ); jQuery.ajax.handleComplete( s, xhr, status, data ); - // Garbage collect - window[ jsonp ] = undefined; - - try { - delete window[ jsonp ]; - } catch( jsonpError ) {} - + + if ( jQuery.isFunction( customJsonp ) ) { + customJsonp( tmp ); + } + else { + // Garbage collect + window[ jsonp ] = undefined; + + try { + delete window[ jsonp ]; + } catch( jsonpError ) {} + } + if ( head ) { head.removeChild( script ); } @@ -436,8 +443,9 @@ jQuery.extend({ } // Fire the complete handlers - jQuery.ajax.handleComplete( s, xhr, status, data ); - + if ( !jsonp ) { + jQuery.ajax.handleComplete( s, xhr, status, data ); + } if ( isTimeout === "timeout" ) { xhr.abort(); } |