我正在使用jquery ui对话框加载MVC部分视图
以下是一些示例代码:
$(function () {
function fSetupDialogs() {
$("#dialog-popup").dialog({
autoOpen: false,
resizable: true,
modal: true
});
}
});
$('body').on('click', '.popup-Edit',
function (e) {
url = $(this).data("url");
$("#dialog-popup")
.load(url)
.html("<img src='/content/images/Spinner.gif'>")
.dialog("option", "title", "Edit " + url.split("/").pop())
.dialog('open');
}
);
尽管偶尔会有一些奇怪的滚动条和其他东西,但这个方法还是很有效的。
问题是当视图抛出一个错误时,我无法解决如何检查它并在jqueryui面板中显示它。
因此,如果视图返回500或401错误,我想捕获该错误并将其显示在对话框中。现在发生的事情是,旋转器GIF永远停在那里。如果我打开F12控制台,就可以看到其中的错误。
我试过用
.error
事件处理程序,它捕获并弹出一个消息框。但我想在弹出窗口中显示:
// This pops up an error alert
$("#dialog-popup")
.load(url)
.error(alert("error"))
.html("<img src='/content/images/Spinner.gif'>")
.dialog("option", "title", "Edit " + url.split("/").pop())
.dialog('open');
如何在对话框中显示内容?这没有效果-旋转器留在那里
// This has no effect - I want to see the words "error"
$("#dialog-popup")
.load(url)
.error($("#dialog-popup").html("error"))
.html("<img src='/content/images/Spinner.gif'>")
.dialog("option", "title", "Edit " + url.split("/").pop())
.dialog('open');
对于奖励积分,我如何使用javascript错误对象来识别401,500,随便什么?-我还没到那一步。