Jquery Ajax 在本地机器上工作而不是在服务器上
Posted
技术标签:
【中文标题】Jquery Ajax 在本地机器上工作而不是在服务器上【英文标题】:Jquery Ajax working in Local Machine not in Server 【发布时间】: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 的例子吗? 【参考方案1】:你可以试试这个吗?
$('#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?"))
$.ajax(
cache: false,
url: '@Url.Action("DeleteTarief", "Onderhoud")',
type: 'POST',
dataType: 'json',
data:
"TariefId":TariefId,
,
success: function (Data)
TariefId = null;
DisplayVerordeningTariefGrid();
);
else
ShowMessage("Please select the tarief to delete");
);
【讨论】:
在本地主机中工作而不在服务器中以上是关于Jquery Ajax 在本地机器上工作而不是在服务器上的主要内容,如果未能解决你的问题,请参考以下文章
在我的 Rails 应用程序中,使用 Jquery Datepicker 在一个页面上工作,而不是在另一个页面上工作
使用 jQuery 在变量中而不是在当前 DOM 中选择内容?