Disable BlockUI for certain ajax calls

Xrender picture Xrender · Mar 11, 2011 · Viewed 9.6k times · Source

I am using the brilliant BlockUI, and have set it up using the default

$(document).ajaxStart($.blockUI).ajaxStop($.unblockUI);

Which is great - except when I add a autocomplete element on the page, and then the blockUI kicks in as soon as the user starts typing. Rather than explicitly set what ajax calls to launch the block UI can anyone think of a way to disable blockUI for certain ajax functions?

Answer

Indranil picture Indranil · Apr 29, 2011

In jQuery an ajax call accepts different settings A set of key/value pairs that configure the Ajax request. All settings are optional.

Now here we have the following:

settings name: global,Type: Boolean, Default: true

Description: Whether to trigger global Ajax event handlers for this request. The default is true. Set to false to prevent the global handlers like ajaxStart or ajaxStop from being triggered. This can be used to control various Ajax Events.

Example:

$.ajax({
        global: false,
        type: "POST",
        url: 'ajax/test.html',
        success: function(data) {
          $('.result').html(data);
          alert('Load was performed.');
        }
});

Above example will stop execution of any ajax start or ajax stop events like blockUI.