The corporate intranet I built heavily uses AJAX calls to load tables and other resources. By default I have a modal dialog box appear with a loading gif to let the user know the page is loading. I set this default up with jQuery's ajaxSetup.
There are a couple of areas where I use a search box with autocomplete. And I noticed every time a character is typed the loading dialog box appears. Any way to disable the ajaxSetup for just that call?
Thanks for the help!
You should be able to pass a new options object with every ajax call to overwrite the settings in the default when needed.
Not sure if your modal is on beforeSend or what have you, but I think you will get the picture from below.
$.ajax({ beforeSend: function() { /* do nothing */ }....
I'm guessing that you set up a handler for a global Ajax event to create the dialog box. These events can be disabled for a specific request like so (from the jQuery documentation):
Global Events
These events are broadcast to all elements in the DOM, triggering any handlers which may be listening. You can listen for these events like so:
$("#loading").bind("ajaxSend", function(){
$(this).show();
}).bind("ajaxComplete", function(){
$(this).hide();
});
Global events can be disabled, for a particular Ajax request, by passing in the global option, like so:
$.ajax({
url: "test.html",
global: false,
// ...
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With