X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fajax.js;h=d22f1528b8a7c14f485e66a74741850d5d6ef0c0;hb=96fd5f18d49bd3a93586c4b8b6c3cdfc337cd067;hp=c255dfebaaeafb6247a13e29eb2d1d4453b57722;hpb=434b87b8a233eb24ec773de801f3adb460fbd0f4;p=jquery.git diff --git a/src/ajax.js b/src/ajax.js index c255dfe..d22f152 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -71,7 +71,7 @@ jQuery.fn.extend({ .filter(function(){ return this.name && !this.disabled && (this.checked || /select|textarea/i.test(this.nodeName) || - /text|hidden|password/i.test(this.type)); + /text|hidden|password|search/i.test(this.type)); }) .map(function(i, elem){ var val = jQuery(this).val(); @@ -95,7 +95,7 @@ jQuery.each( "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".sp var jsc = now(); jQuery.extend({ - + get: function( url, data, callback, type ) { // shift arguments if data argument was ommited if ( jQuery.isFunction( data ) ) { @@ -143,13 +143,15 @@ jQuery.extend({ url: location.href, global: true, type: "GET", - timeout: 0, contentType: "application/x-www-form-urlencoded", processData: true, async: true, + /* + timeout: 0, data: null, username: null, password: null, + */ // Create the request object; Microsoft failed to properly // implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available // This function can be overriden by calling jQuery.ajaxSetup @@ -265,12 +267,17 @@ jQuery.extend({ done = true; success(); complete(); + + // Handle memory leak in IE + script.onload = script.onreadystatechange = null; head.removeChild( script ); } }; } - head.appendChild(script); + // Use insertBefore instead of appendChild to circumvent an IE6 bug. + // This arises when a base node is used (#2709 and #4378). + head.insertBefore( script, head.firstChild ); // We handle everything using the script element injection return undefined; @@ -378,6 +385,9 @@ jQuery.extend({ // Fire the complete handlers complete(); + if ( isTimeout ) + xhr.abort(); + // Stop memory leaks if ( s.async ) xhr = null; @@ -392,14 +402,8 @@ jQuery.extend({ if ( s.timeout > 0 ) setTimeout(function(){ // Check to see if the request is still happening - if ( xhr ) { - if( !requestDone ) - onreadystatechange( "timeout" ); - - // Cancel the request - if ( xhr ) - xhr.abort(); - } + if ( xhr && !requestDone ) + onreadystatechange( "timeout" ); }, s.timeout); } @@ -482,7 +486,7 @@ jQuery.extend({ if ( xml && data.documentElement.tagName == "parsererror" ) throw "parsererror"; - + // Allow a pre-filtering function to sanitize the response // s != null is checked to keep backwards compatibility if( s && s.dataFilter ) @@ -499,7 +503,7 @@ jQuery.extend({ if ( type == "json" ) data = window["eval"]("(" + data + ")"); } - + return data; },