- // If the type is "script", eval it in global context
- if ( type == "script" )
- jQuery.globalEval( data );
+ // Allow a pre-filtering function to sanitize the response
+ // s is checked to keep backwards compatibility
+ if ( s && s.dataFilter ) {
+ data = s.dataFilter( data, type );
+ }
+
+ // The filter can actually parse the response
+ if ( typeof data === "string" ) {
+
+ // If the type is "script", eval it in global context
+ if ( type === "script" ) {
+ jQuery.globalEval( data );
+ }