0

I have a "global" script called global.js which is included on the header of the page.

$(document).ajaxStart(function(){
    $('#ajax_loading').html('<div><img src="load.gif" /></div>');
    $('#ajax_loading').show();
}).ajaxStop(function(){
    $('#ajax_loading').hide();
});

On this_page.js I've tried

$(document).ajaxStart(function(){
    return;
}).ajaxStop(function(){
    return;
});

or

$(document).ajaxStart(function(){
    event.stopImmediatePropagation();
}).ajaxStop(function(){
    event.stopImmediatePropagation();
});

but the global.js functions are still executed.

Now on a page I want that those two functions (ajaxStart and ajaxStop) aren't executed on ajax calls. How can I solve the problem?

global.js is included before this_page.js.

5
  • Is there anything else inside global.js? Commented Apr 15, 2014 at 2:28
  • Yes another function which is not used on that page Commented Apr 15, 2014 at 2:29
  • Then why do you need to include that script file on that page? Why not just leave it out? Commented Apr 15, 2014 at 2:30
  • I believe he means it is a global script i.e. to be included on every page Commented Apr 15, 2014 at 2:31
  • This script is included on the header, so if I include the header the script also comes in.... Maybe in the future I'll add more function that will be used on this page Commented Apr 15, 2014 at 2:31

1 Answer 1

1

.ajaxStart() and .ajaxStop() simply attach another handler. To truly disable the handler you must call:

$.ajaxSetup({
    global: false
});

before your ajax code.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.