0
我正在使用以下脚本并成功从数据库中删除底层记录。但点击确认后,根本没有任何反应。这意味着我必须关闭两个弹出窗口,然后在浏览器上点击F5以查看结果。我尝试过很多事情,但必须有一些简单的我失踪这里JQUERY不关闭弹出窗口和刷新页面
function deletePayment(customerPaymentId) {
//alert(customerPaymentId);
bootbox.confirm("Are you sure? This payment will be logically deleted", function (result) {
if (result) {
var url = '/CustomerPayment/Delete';
var data = {
id: customerPaymentId
};
$.post(url, data, function() {
window.location.reload();
});
}
});
return false;
}
控制器下面的代码:
//[HttpPost, ActionName("Delete")]
//[ValidateAntiForgeryToken]
//[Authorize(Roles = "Delete")]
public ActionResult Delete(int id)
{
CustomerPayment obj = _db.GetCustomerPayment(id);
_db.Edit(obj);
obj.TransactionDateTimeEnd = DateTime.Now;
_db.Save();
return View("Index", new { id = obj.CustomerId});
}
取出返回false?你确定你还包括Jquery吗? – KyleK
查看$ .post的jquery文档:http://api.jquery.com/jquery.post/ 您只为$ .post实现'success'处理程序,所以如果该帖子失败(不以200(OK)状态码返回),窗口永远不会重新加载。 –
如果你只是打算调用'window.location.reload();'来重新加载页面,那么没有必要使用ajax。 –