gpt4 book ai didi

c# - jquery 模式弹出窗口 asp.net mvc 中显示的错误页面

转载 作者:太空宇宙 更新时间:2023-11-03 13:41:11 24 4
gpt4 key购买 nike

我用它来加载弹出窗口:

$(document).ready(function () {
$(".openDialog").live("click", function (e) {
e.preventDefault();
$("<div></div>")
.addClass("dialog")
.attr("id", $(this).attr("data-dialog-id"))
.appendTo("body")
.dialog({
title: $(this).attr("data-dialog-title"),
close: function () { $(this).remove(); },
width: 400,
modal: true
})
.load(this.href);
});

问题是当我单击将在弹出窗口中打开的任何链接时,如果出现任何错误,整个错误页面都会加载到弹出窗口中。我希望将用户重定向到未经授权或任何其他错误页面,而不是将错误页面加载到模式弹出窗口中。

这适用于任何不会在弹出窗口中打开的链接。

仅供引用,我已启用自定义错误模式。

<customErrors mode="On" defaultRedirect="~/Errors/General/">
<error statusCode="404" redirect="~/Errors/Http404/" />
</customErrors>

最佳答案

首先调用 .load() 加载内容并检测错误,然后调用对话框。例如:

var dialog = $('<div></div>');
dialog.load('url', function (response, status, xhr) {
if (status == "error") {
alert("Something went wrong opening the dialog.");
} else {
dialog.dialog();
}
});

关于c# - jquery 模式弹出窗口 asp.net mvc 中显示的错误页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16961628/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com