Question

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?

Was it helpful?

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); 
    }); 
}); 

OTHER TIPS

You can use jQuery's delay([time in seconds]) function. As far as I know, setTimeout works on another workflow than the rest of the script.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top