The purpose of the prefilter is to provide a way to delay the execution of the success callback of an ajax call. Sometimes it is good to delay the call in order to show a message while the ajax call is loading.
$("#threshold-ajax-call").click(function() {
$.ajax({
url: "http://www.thetimbanks.com/demos/jquery/successThreshold/ajaxfile.html",
type: "GET",
beforeSend: function() {
$("#ajax-loading-message").show();
},
successThreshold: 3000,
success: function(){
$("#ajax-loading-message").hide();
}
});
return false;
});
Basic ajax call Something is loading!