Disable BlockUI for specific ajax calls

I use brilliant BlockUI and configured it using standard

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

This is great - except when I add an autocomplete element on the page, and then the UI block starts as soon as the user starts typing. Instead of explicitly specifying which ajax calls to launch the block user interface, can anyone think of a way to disable blockUI for specific ajax functions?

+5
source share
2 answers

You can do something like this:

var dontBlock = false;

$(document).ajaxStart(function(){
    if(!dontBlock)
        $.blockUI();
}).ajaxStop($.unblockUI);

// And in the ajax methods (to be excluded), set dontBlock accordingly

$('#autocomplete').keydown(function(){
    dontBlock = true;
    $.ajax({
        // url, data etc.
        success: function(){ dontBlock = false; }
    });
});
+6
source

jQuery ajax- . /, Ajax. .

:

: , : , : true

: Ajax . - true. false, , ajaxStart ajaxStop. Ajax.

:

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

ajax ajax, blockUI.

+23

All Articles