我已经实现了块UI,因为这个请求可能需要一点时间,当ajax请求启动时,所有内容都按预期工作。
但是当ajax请求完成并显示msgbox时,UI不会取消阻止!
有什么想法吗?
我正在使用IE8。
$().ajaxStart($.blockUI);
$().ajaxStop($.unblockUI);
function ChangeCompanyState(companyId, state) {
var parameters = "{companyId:" + companyId + ",state:\"" + state + "\"}";
$.ajax({
type: "POST",
url: "Ajax/AjaxFragments.aspx/ChangeCompanyState",
data: parameters,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
if (msg.d.length > 1) {
alert(msg.d);
$.unblockUI();
}
else {
//Theres no message to process success.
window.location.reload();
}
}
});
}
答案 0 :(得分:7)
$.unblockUI();
$(".blockUI").fadeOut("slow");
答案 1 :(得分:4)
我有相同的,并通过在unblockUI句子中使用括号来解决。
// block when ajax activity starts
function beginRequestHandler(sender, args) {
$.blockUI({ message: '<h1><img src="loading.gif" /> Just a moment...</h1>' });
}
// unblock when ajax activity stops
function endRequestHandler(sender, args) {
$.unblockUI(); // previously was $.unblockUI;
}
HTH 米尔顿
答案 2 :(得分:0)