我目前已对其进行了设置,以便在 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);
}
});
});
我忽略了什么明显的东西吗?这甚至可能吗?