最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - functionality of datafilter in Ajax jQuery - Stack Overflow

matteradmin8PV0评论

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 0
Add a ment  | 

1 Answer 1

Reset to default 4

An 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);
}
Post a comment

comment list (0)

  1. No comments so far