X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;ds=sidebyside;f=src%2Fajax.js;h=bda79b50aa9d1887f52b9a3eca33f4796147bcef;hb=c9c024280abd20b4eef4a2dc280fa7f1d7be02f9;hp=a5ee4b7cc91efe69eb43aeeca90cfd9dfd8e5e4b;hpb=9d9c4d2a516216378f4eec0bc27a2cc1cfc78d53;p=jquery.git diff --git a/src/ajax.js b/src/ajax.js index a5ee4b7..bda79b5 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -12,8 +12,6 @@ jQuery.fn.extend({ url = url.slice(0, off); } - callback = callback || function(){}; - // Default to a GET request var type = "GET"; @@ -56,7 +54,8 @@ jQuery.fn.extend({ // If not, just inject the full result res.responseText ); - self.each( callback, [res.responseText, status, res] ); + if( callback ) + self.each( callback, [res.responseText, status, res] ); } }); return this; @@ -480,14 +479,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; },