【发布时间】:2021-10-12 22:22:55
【问题描述】:
HTML 代码
$('#btnTariefVerwijderen').click(function () {
if (TariefId != undefined && TariefId != "" && TariefId != null) {
if (window.confirm("Weet u zeker dat u de gesselecteerde rij(en) wilt verwijderen uit de database?")) {
var url = '/Onderhoud/DeleteTarief?TariefId=' + TariefId;
$.ajax({
cache: false,
type: "GET",
url: url,
contentType: "application/json; charset=utf-8",
//data: { objectId: objectId, type: type },
dataType: "json",
success: function (Data) {
TariefId = null;
DisplayVerordeningTariefGrid();
}
});
}
}
else
ShowMessage("Please select the tarief to delete");
});
C#代码
public ActionResult DeleteTarief(decimal TariefId)
{
if (ModelState.IsValid)
{
_onderhoudRepository.DeleteTariefItem(TariefId,HttpContext.User.Identity.Name);
//return RedirectToAction("SelecterenPuttenData", new { objectId = objectId, type = type });
return Json(new { success = true }, JsonRequestBehavior.AllowGet);
}
else
{
return Json(new { success = false }, JsonRequestBehavior.AllowGet);
}
}
该功能仅在本地计算机中触发,而不在服务器中触发。有人可以帮我从这里出去吗。 Jquery 文件在本地 Visual Studio 中运行良好
【问题讨论】:
-
您遇到什么错误?你检查你的网络标签了吗?
-
@johnSmith 在 localhost [Visual Studio] 中我没有收到任何错误,但在部署到服务器后我收到以下错误“GET webl.com/Controller/… net::ERR_EMPTY_RESPONSE”这在控制台中
-
TariefId 的奇怪类型小数?你确定不是错字吗?你能举一个 TariefId 的例子吗?
标签: javascript c# jquery ajax asp.net-mvc