weixin_33749131 2015-07-09 02:32 采纳率: 0%
浏览 125

如何使用AjaxPrefilter?

Can you please explain to me the simplest way on how the AJAX prefiltering in jQuery works? Sorry I'm a newbie in using AJAX.

Is it for customizing requests in the server? Thanks.

I'm referring to this site but still can't get it.

  • 写回答

2条回答 默认 最新

  • 衫裤跑路 2015-08-10 00:52
    关注

    Have a read of the documentation at http://api.jquery.com/jquery.ajaxprefilter/ this function is basically used to alter the data that is sent through to your server before it is sent.

    An example I have used specifically is

    $.ajaxPrefilter(function (options, originalOptions, jqXHR) {
        options.data = $.param($.extend(originalOptions.data||{}, {
            timeStamp: new Date().getTime()
        }));
    });
    

    Which takes the original data that was to be sent through an adds another parameter with a timestamp. This was useful to get around iOS's problem with caching post requests without having to add a timestamp to each individual request.

    评论

报告相同问题?