X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Fajax%2Fajax.js;h=d72ddc6b7351b4323c5864b5711f7b2069074775;hb=78db847ef201a66f88e9ad330b2e51c65c58abb3;hp=9c9a5df3646d7f53e8d8430dc522d39144ae91c1;hpb=bfe5f891068af9f86d7be288ad0da7b442427d9c;p=jquery.git diff --git a/src/ajax/ajax.js b/src/ajax/ajax.js index 9c9a5df..d72ddc6 100644 --- a/src/ajax/ajax.js +++ b/src/ajax/ajax.js @@ -408,9 +408,6 @@ jQuery.extend({ }); }, - // timeout (ms) - //timeout: 0, - /** * Set the timeout in milliseconds of all AJAX requests to a specific amount of time. * This will make all future AJAX requests timeout after a specified amount @@ -637,10 +634,6 @@ jQuery.extend({ // Set header so the called script knows that it's an XMLHttpRequest xml.setRequestHeader("X-Requested-With", "XMLHttpRequest"); - // Make sure the browser sends the right content length - if ( xml.overrideMimeType ) - xml.setRequestHeader("Connection", "close"); - // Allow custom headers/mimetypes if( s.beforeSend ) s.beforeSend(xml); @@ -662,10 +655,12 @@ jQuery.extend({ var status; try { - status = jQuery.httpSuccess( xml ) && isTimeout != "timeout" ? - s.ifModified && jQuery.httpNotModified( xml, s.url ) ? "notmodified" : "success" : "error"; + status = isTimeout == "timeout" && "timeout" || + !jQuery.httpSuccess( xml ) && "error" || + s.ifModified && jQuery.httpNotModified( xml, s.url ) && "notmodified" || + "success"; // Make sure that the request was successful or notmodified - if ( status != "error" ) { + if ( status != "error" && status != "timeout" ) { // Cache Last-Modified header, if ifModified mode. var modRes; try { @@ -792,7 +787,7 @@ jQuery.extend({ // Get the JavaScript object, if JSON is used. if ( type == "json" ) - eval( "data = " + data ); + data = eval("(" + data + ")"); // evaluate scripts within html if ( type == "html" ) @@ -833,13 +828,16 @@ jQuery.extend({ // evalulates a script in global context // not reliable for safari globalEval: function( data ) { - if ( window.execScript ) - window.execScript( data ); - else if ( jQuery.browser.safari ) - // safari doesn't provide a synchronous global eval - window.setTimeout( data, 0 ); - else - eval.call( window, data ); + data = jQuery.trim( data ); + if ( data ) { + if ( window.execScript ) + window.execScript( data ); + else if ( jQuery.browser.safari ) + // safari doesn't provide a synchronous global eval + window.setTimeout( data, 0 ); + else + eval.call( window, data ); + } } });