X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Fajax.js;h=2c4f13cb2c3b1992b19863668432b34ec7ee1f81;hb=266facc08a2e1c8cb5a7a60de304da47657f2227;hp=7cf280ab33ab60f94f0bbbfc358ffde1cac25857;hpb=8effe3a7dee91c833cc1774646da9d743600c64c;p=jquery.git diff --git a/src/ajax.js b/src/ajax.js index 7cf280a..2c4f13c 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -237,17 +237,25 @@ 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; + + if ( jQuery.isFunction( customJsonp ) ) { + customJsonp( tmp ); - try { - delete window[ jsonp ]; - } catch( jsonpError ) {} + } else { + // Garbage collect + window[ jsonp ] = undefined; + try { + delete window[ jsonp ]; + } catch( jsonpError ) {} + } + if ( head ) { head.removeChild( script ); } @@ -436,7 +444,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(); @@ -474,7 +484,7 @@ jQuery.extend({ // Send the data try { - xhr.send( type === "POST" || type === "PUT" || type === "DELETE" ? s.data : null ); + xhr.send( (type !== "GET" && s.data) || null ); } catch( sendError ) { jQuery.ajax.handleError( s, xhr, null, e );