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.
asked Apr 15, 2014 at 2:24
Perocat
1,5217 gold badges25 silver badges50 bronze badges
-
Is there anything else inside global.js?Ethan Brouwer– Ethan Brouwer2014年04月15日 02:28:52 +00:00Commented Apr 15, 2014 at 2:28
-
Yes another function which is not used on that pagePerocat– Perocat2014年04月15日 02:29:43 +00:00Commented 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?Ethan Brouwer– Ethan Brouwer2014年04月15日 02:30:37 +00:00Commented Apr 15, 2014 at 2:30
-
I believe he means it is a global script i.e. to be included on every pagewavemode– wavemode2014年04月15日 02:31:32 +00:00Commented 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 pagePerocat– Perocat2014年04月15日 02:31:59 +00:00Commented Apr 15, 2014 at 2:31
1 Answer 1
.ajaxStart() and .ajaxStop() simply attach another handler. To truly disable the handler you must call:
$.ajaxSetup({
global: false
});
before your ajax code.
answered Apr 15, 2014 at 2:36
wavemode
2,1171 gold badge19 silver badges24 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-js