jQuery blockUI and AJAX POST
- by oompahloompah
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?