Bug Tracker

Changeset 5620

Show
Ignore:
Timestamp:
05/16/08 16:39:27 (6 months ago)
Author:
aflesler
Message:

jquery ajax: Closes #2567, additional setting for $.ajax called 'dataFilter'. It's an optional function that receives the ajax response, and returns the sanitized version.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/jquery/src/ajax.js

    r5614 r5620  
    337337                    try { 
    338338                        // process the data (runs the xml through httpData regardless of callback) 
    339                         data = jQuery.httpData( xhr, s.dataType ); 
     339                        data = jQuery.httpData( xhr, s.dataType, s.dataFilter ); 
    340340                    } catch(e) { 
    341341                        status = "parsererror"; 
     
    461461    }, 
    462462 
    463     httpData: function( xhr, type ) { 
     463    httpData: function( xhr, type, filter ) { 
    464464        var ct = xhr.getResponseHeader("content-type"), 
    465465            xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0, 
     
    468468        if ( xml && data.documentElement.tagName == "parsererror" ) 
    469469            throw "parsererror"; 
     470             
     471        // Allow a pre-filtering function to sanitize the response 
     472        if( filter ) 
     473            data = filter( data, type ); 
    470474 
    471475        // If the type is "script", eval it in global context