jquery ajax: closes #3231. The ajax setting 'dataFilter' can also parse the response.
authorAriel Flesler <aflesler@gmail.com>
Thu, 7 Aug 2008 20:41:05 +0000 (20:41 +0000)
committerAriel Flesler <aflesler@gmail.com>
Thu, 7 Aug 2008 20:41:05 +0000 (20:41 +0000)
src/ajax.js

index a5ee4b7..885c819 100644 (file)
@@ -480,14 +480,18 @@ jQuery.extend({
                if( s && s.dataFilter )
                        data = s.dataFilter( data, type );
 
-               // If the type is "script", eval it in global context
-               if ( type == "script" )
-                       jQuery.globalEval( data );
+               // The filter can actually parse the response
+               if( typeof data == 'string' ){
 
-               // Get the JavaScript object, if JSON is used.
-               if ( type == "json" )
-                       data = eval("(" + data + ")");
+                       // If the type is "script", eval it in global context
+                       if ( type == "script" )
+                               jQuery.globalEval( data );
 
+                       // Get the JavaScript object, if JSON is used.
+                       if ( type == "json" )
+                               data = eval("(" + data + ")");
+               }
+               
                return data;
        },