The isTimeout fix from #970 was causing unintended status bugs (fixed). This also...
[jquery.git] / src / ajax / ajax.js
index 102c7f9..d72ddc6 100644 (file)
@@ -655,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 {
@@ -785,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" )
@@ -826,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 );
+               }
        }
 
 });