Shrinath
Shrinath

Reputation: 8118

Hide spinner only for specific ajax

I am using a spinner using tutorial shown here

there are 3 functions running ajax calls I want to hide it for only a specific function running ajax call, how to do this ?

Currently my code for adding spinner for ajax call is this :

  $(document).ready(function(){
      $("#spinner").bind("ajaxSend", function() {
                $(this).show();
            }).bind("ajaxStop", function() {
                $(this).hide();
            }).bind("ajaxError", function() {
                $(this).hide();
      });
  });

its exactly what is shown in the tutorial which I've linked above. Now how do I make it work only for 2 ajax calling functions out of 3 ?

ps : Should I unbind it and bind it everytime ??

Upvotes: 1

Views: 1109

Answers (1)

oezi
oezi

Reputation: 51817

for an ajax-call that doesn't use ajaxStart/ajaxStop (which is what you're using to show/hide your spinkner i think, theres no information about that in your question) just set global: false like this:

$.ajax({
  url: "test.php",
  context: document.body,
  global: false,
  success: function(data){
    $('#test').html(data);
});

for more information, take a look at the documentation.

Upvotes: 2

Related Questions