Latest news
Home » jQuery » Global Ajax Event Handlers

Global Ajax Event Handlers

These following Global Ajax Events to be called at the time of initialization ,completion,success,send..etc. These type of events are triggered on each Ajax request, if the global property in jQuery.ajaxSetup() is true .
ajaxComplete():This global event to be triggered when Ajax requests complete.
.ajaxError(): This global event to be triggered when Ajax requests complete with an error
.ajaxSend(): This global event to be triggered before an Ajax request is sent
.ajaxStart(): This global event to be triggered when the first Ajax request begins
.ajaxStop(): This global event to be triggered when all Ajax requests have completed
.ajaxSuccess():This global event to be triggered when an Ajax request completes successfully Example Code
$( document ).ajaxSuccess(function( event, request, settings ) { if(settings.url != "companies/getnewtoken/") {
$.ajax({ type: "get", url: "companies/getnewtoken/", success: function(result) {
$("input[name='token']").val(result); globaltoken = result; //alert(result)
//alert($("input[name='token']").val()); },
error: function(){ console.log('Error while request..'); }
}); }
});

Leave a Reply

x

Check Also

How to print Codeigniter upload error

if you want to display errors on upload functionality in codeigniter. Use the following function ...