From bf6f7e7a63cb3d43da2fcc98c81690d2dc1ac54b Mon Sep 17 00:00:00 2001 From: Ariel Flesler Date: Thu, 7 Aug 2008 20:41:05 +0000 Subject: [PATCH] jquery ajax: closes #3231. The ajax setting 'dataFilter' can also parse the response. --- src/ajax.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/ajax.js b/src/ajax.js index a5ee4b7cc..885c8193e 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -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; },