我下面有一个锚类
<a class="delete" href="@Url.Action("methodname","controller", new { id= "18"})">delete</a>
和一个DIV级以下
<div id="confirmation" hidden = "hidden"> <p>Are you sure you want to delete this item?</p> </div>
下面是jquery的内容
/ 当用户点击删除时,下面将打开div确认框。
$(document).ready(function () {
$(".delete").click(function () {
$('#confirmation').dialog('open');
return false;
});
});
/ 我有两个按钮continue和cancel,一旦用户点击continue,我需要调用URl动作,参数是
$(document).ready(function () {
$('#confirmation').dialog({
autoOpen: false
buttons: {
"Continue": function () {
//code here
$(this).dialog("close");
},
"Cancel": function () {
$(this).dialog("close");
}
}
});
});
你可以这样做
$.ajax({
type: "POST",
data: {
id: id,
},
url: "/Controller/Method",
dataType: "json",
success: function (result) {
window.location.href = "/Controller/Method";
},
error: function (result) {
alert(result.responseText);
},
});