全部,
我在模态标题内创建了一个按钮,单击该按钮应将您注销。但是,这没有发生。当我单击按钮时,页面会再次重新加载,并显示模式。有谁知道是什么原因造成的?
这就是我设置模态的方式。在模态标题内,我添加了代码,以便用户单击“ x”时,应将其签名。
<div id="myModal2" class="modal fade" role="dialog" data-keyboard="false" data-backdrop="static">
<div class="modal-dialog">
<div class="modal-content" style="text-align:center">
<div class="modal-header">
@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "formlogoff" }))
{
<span name="requestVerificationToken">@Html.AntiForgeryToken()</span>
<button id="signoff" class="close">x</button>
}
</div>
<div class="modal-body">
<div>
<p>After the free trial you will automatically started your paid monthly subscriptio</p>
</div>
<input type="checkbox" name="ThirtyTrial" id="ThirtyTrial" class="filled-in chk-col-deep-orange" required>
<label for="ThirtyTrial">Please do not show this to me again.</label>
</div>
<div class="modal-footer" style="text-align:center">
<a class="modal-free-trial" onclick="createModal('@Url.Action("AddCustomer", "Billing")')">Add Payment</a>
</div>
</div>
</div>
</div>
这是我的Ajax退出请求
$('#signoff').on('click', function (event) {
event.preventDefault()
var form = $('#formlogoff');
var token = $('input[name="__RequestVerificationToken"]', form).val();
$.ajax({
url: '/Account/LogOff',
data: { __RequestVerificationToken: token },
type: "POST",
success: function (data) { window.location.href = '/Account/Login' }
});
});
答案 0 :(得分:0)
在click
回调的末尾,您可以尝试return false;
吗?
$('#signoff').on('click', function (event) {
event.preventDefault()
// ...
$.ajax({
// ...
});
return false;
});
答案 1 :(得分:0)
我从签核功能中删除了event.preventDefault()