How do I use the AjaxPrefilter?

Could you please explain to me the simplest way of working with AJAX prefiltering in jQuery? Sorry I am new to using AJAX.

Is this for setting up queries on the server? Thank.

I mean this site but still can't get it.

+3


source to share


1 answer


Read the documentation at http://api.jquery.com/jquery.ajaxprefilter/ , this function is mainly used to modify the data sent to your server before it was sent.

As an example, I specifically used



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

      

Which takes the original data that should have been sent by adding another parameter with a time stamp. This was useful for solving the iOS issue of caching mail requests without having to add a timestamp to every single request.

+2


source







All Articles