jQuery blockUI and AJAX POST
        Posted  
        
            by 
                oompahloompah
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by oompahloompah
        
        
        
        Published on 2011-02-17T07:22:38Z
        Indexed on 
            2011/02/17
            7:25 UTC
        
        
        Read the original article
        Hit count: 247
        
I am using jQuery BlockUI in a project. For a particular user action, I want to block the UI, and then POST data to the server. When the timeout event occurs OR the server returns, I want to unblock the page.
I can't seem to implement this behaviour. This is what I have so far (not working)
$(document).ready(function(){
    $('#test').click(function(event){
        $.blockUI({ message: $('#syntax-chk') });
        $.ajax({
              type: 'POST',
              url: 'www.example.com',
              data: somedata,
              dataType: "json"
        });
        setTimeout(function() {
                $.unblockUI({
                    onUnblock: function(){ 
                        alert('onUnblock');
                    }
                });
            }, 2000);
});
can anyone spot what I may be doing wrong?
© Stack Overflow or respective owner