gpt4 book ai didi

javascript - jQuery 对话框在 Ajax 调用中未触发

转载 作者:行者123 更新时间:2023-12-02 18:35:01 25 4
gpt4 key购买 nike

我目前已对其进行设置,以便在 AJAX 发布成功时显示一个对话框。 AJAX 发布成功(下面的警报正在触发),但对话框未显示。我不明白为什么。这是我的标记:

<a data-eventid="@item.EventId" id="raffle-@item.EventId" class="raffle-charity-button" href="#"><img src="~/Images/Raffle.png" alt="Raffle" title="Pick a winner!"/></a>

<div id="raffle-event-dialog">
<p class="dialogDisplayWinner">
</p>
</div>

...这是我的脚本:

$(".raffle-charity-button").click(function() {
charityEventId = $(this).data("eventid");
//charityEventId = parseInt($(this).attr("id").split("-")[1]);
var url = "@Url.Action("Raffle", "DonationEvent")";
var postData = {
id: charityEventId
};
$.ajax({
type: "POST",
url: url,
data: postData,
datatype: "json",
success:
function(data) {
if (data != "") {
if (data.Success == "false") {
window.location = "../Error";
} else {
var originalVerbiage = "The winner of the raffle is... "
$(".dialogDisplayWinner").empty();
$(".dialogDisplayWinner").append(originalVerbiage + "test");

$("#raffle-event-dialog").dialog({
modal: true,
autoOpen: false,
buttons: {
"OK": function() {
$("#raffle-event-dialog").dialog("close");
}
},
resizable: false
}
);
alert(data.Success);
}
}
},
error:
function(jqxhr, ajaxOptions, thrownError) {
alert("An error occurred: error Code(" + jqxhr.status + ") message: " + jqxhr.responseText);
}
});
});

这是我忽略的明显事情吗?这可能吗?

最佳答案

您正在创建对话框,并将选项autoOpen 设置为false,因此该对话框不会自动打开(请查看文档 here )。将此值更改为 true 或稍后调用打开对话框:

$("#raffle-event-dialog").dialog('open');

关于javascript - jQuery 对话框在 Ajax 调用中未触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17424755/

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