jQuery ajax调用将无法访问控制器:无法加载资源:服务器以状态500(内部服务器错误)响应 [英] Jquery ajax call wont access the controller: Failed to load resource: the server responded with a status of 500 (Internal Server Error)
本文介绍了jQuery ajax调用将无法访问控制器:无法加载资源:服务器以状态500(内部服务器错误)响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直无法加载资源:服务器响应状态为500(内部服务器错误),指示对我的控制器方法的调用不起作用,我不知道为什么:
I keep getting Failed to load resource: the server responded with a status of 500 (Internal Server Error) indicating that the call to my controller method isnt working and I dont know why:
var user = "founder";
var clanName = "superClan";
var SuspensionDate = Date.now;
$.ajax({
url: '@Url.Action("SuspendUserFromClan", "ChatMethods")',
type: "POST",
contentType: "application/json; charset=utf-8",
data: { 'ClanName': clanName, 'UserToSuspend': userToAdd, 'DateSuspendedTill': SuspensionDate },
dataType: "json",
traditional: true,
success: function (data, status, xhr) {
alert(data);
},
error: function () {
alert("An error has occured!!!");
}
});
我的控制器:
public JsonResult SuspendUserFromClan(string ClanName, string UserToSuspend, DateTime DateSuspendedTill)
{
...
}
推荐答案
var SuspensionDate = new Date();
$('#SuspendUser').on("click", function () {
$.ajax({
url: '@Url.Action("SuspendUserFromClan", "ChatMethods")',
type: "POST",
// contentType: "application/json; charset=utf-8",
data: { 'ClanName': clanName, 'UserToSuspend': userToAdd, 'DateSuspendedTill': SuspensionDate.toUTCString() },
dataType: "json",
traditional: true,
success: function (data, status, xhr) {
alert(data);
},
error: function () {
alert("An error has occured!!!");
}
});
});
解决了此问题.
这篇关于jQuery ajax调用将无法访问控制器:无法加载资源:服务器以状态500(内部服务器错误)响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文