3

I use something like the following for handling an ajax loading timer:

 $body = $("body"); $(document).on({ ajaxStart: function() { $body.addClass("loading"); }, ajaxStop: function() { $body.removeClass("loading"); } }); 

but there are some specific calls where I want this suppressed. How would I do this? I don't want to manually removed the loading class.

1 Answer 1

4

You can add global:false option to specific ajax calls.

ajaxStart and ajaxStop are global handlers. If you don't want some ajax calls to be suppressed, just add global:false to your ajax.

1

$.ajax({ url:'some url', success: function(){ // this ajax will trigger ajax start and stop } }); 

2

$.ajax({ url:'some url', success: function(){ // this ajax will not trigger ajax start and stop as it has global set to false }, global: false }); 
Sign up to request clarification or add additional context in comments.

1 Comment

@timpone glad to have helped ;)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.