Search code examples
jqueryjquery-blockui

Block UI using jQuery


I use jQuery to block ui like this

$('#send').click(function() {
       $.blockUI({ message: 
       '<p id="loading"><img src="images/busy.gif" /> processing...</p>'});  
        send();
       $(document).ajaxStop($.unblockUI); 
       setTimeout($.unblockUI, 2000); 

}); 

send() does some background processing and sets a response message in #loading tag. After the process is finished I want this message to stay for some seconds so I use the setTimeout but this does not work.

Any ideas?


Solution

  • Your script seems to call the unblockUI using ajaxStop already? Have you tried to remove this line or set your timeout within the ajaxStop handler?

    UPDATE

    You could try this:

    $('#send').click(function() {
        $.blockUI({ message: '<p id="loading"><img src="images/busy.gif" /> processing...</p>'});  
        send();
        $(document).ajaxStop(function(){
            setTimeout($.unblockUI, 2000); 
        }); 
    });