Reputation: 4440
I am using BlockUI
to help prevent interaction on my pages during ajax requests, with this simple command.
$(document)
.ajaxStart($.blockUI)
.ajaxStop($.unblockUI);
This works most of the time. But there are situations, such as during errors, where I want to update the contents to display the error messages returned from my server.
At first, my thought was that I had to just remove this global behavior and do every block on a completely manual basis; Which I would like to avoid for obvious reasons.
So is there any way to update the contents of the blocking message while it is still running? Such as in the error
function call back from a jQuery $.ajax
request? Like this?
$.ajax({
// information
}).success(function (data) {
// completed behavior
}).error(function (xhr, status, exception) {
// update the blocked error message here with data returned
});
I thought just calling $.block
again would work, but it doesn't seem to.
Upvotes: 3
Views: 2218
Reputation: 1889
You could try something like this
<div id="msg"></div>
$(document)
.ajaxStart($.blockUI({ message: $('#msg') }))
.ajaxStop($.unblockUI);
.ajaxError(function(){$("#msg").html("error!");});
Upvotes: 3