最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - functionality of datafilter in Ajax jQuery - Stack Overflow

programmeradmin2浏览0评论

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);
}
发布评论

评论列表(0)

  1. 暂无评论