I have not been able to get a clear idea of the purpose of datafilter in jquery.
while searching I found the following
datafilter: A function to be used to handle the raw response data of XMLHttpRequest. This is a pre-filtering function to sanitize the response.
Can anyone give me a clear idea? Am new to jquery and Ajax.
I have not been able to get a clear idea of the purpose of datafilter in jquery.
while searching I found the following
datafilter: A function to be used to handle the raw response data of XMLHttpRequest. This is a pre-filtering function to sanitize the response.
Can anyone give me a clear idea? Am new to jquery and Ajax.
Share Improve this question edited Oct 14, 2015 at 18:59 MER 1,57120 silver badges27 bronze badges asked Apr 13, 2013 at 7:18 user2156088user2156088 2,4306 gold badges22 silver badges24 bronze badges 01 Answer
Reset to default 4An example of WHAT it could be for could be a custom data pression implementation. Say you're returning xml or json and you want to press is. You could potentially add a dataFilter that depresses the raw data and returns it.
Note that the dataFilter runs PRIOR to the parser. So as long as you return valid json, xml, etc the parser will e along and pass on the response in the correct type.
ex:
$.ajaxSetup({dataFilter:depressRaw}); //global depression for all calls from the page
function depressRaw(data, dataType){
return someDepressionFunction(data);
}