I have the following code that I'm running on every page:
$(document).ready(function () {
$(document).ajaxStart($.blockUI);
$(document).ajaxStop($.unblockUI);
$("form").submit(function() {
if ($(this).valid() == true) {
$.blockUI();
}
});
});
This code allows me to present a "loading..." message during both AJAX calls and form posts. In general, this is working fine. However, I have a scenario in which I need to make an AJAX call to validate a piece of data prior to making a form post, as follows:
$.ajax({
url: '/Item/VerifyFolder/',
type: 'POST',
dataType: 'json',
data: {
folderName: folderName
},
success: function (data, textStatus, jqXHR) {
$.unblockUI();
if (data.folderItemExists == true)
{
$("form").submit();
}
else
{
if (confirm("The folder specified for this item does not exist. Do you want to create it?") == true)
{
// ...
$("form").submit();
}
else
{
return false;
}
}
},
error: function (jqXHR, textStatus, errorThrown) {
DisplayError(textStatus);
}
});
In my AJAX success callback, I start off by calling $.unblockUI()
. However, it seems to have no effect. As a result, the "loading..." message is still displayed when the alert pops up.
I've seen various posts online about problems with IE 8 and the unblockUI method (misformed HTML, needing a meta tag, etc) but I have yet to find a solution that works.
Any guidance would be appreciated. Thanks!