[英]I have internal server error 500 when I tried to post json in Jquery ajax
When I try to send json JSON.stringify(coords); 当我尝试发送JSON JSON.stringify(coords); or above code I get error message but I try when the data is empty like data:{} the code works correctly.
或以上代码,我会收到错误消息,但是我尝试在数据为空时使用数据: How can I solve this problem?
我怎么解决这个问题?
$.ajax({
type: "POST",
data: {"yagiz":"aabb"},
dataType: 'json',
url: url,
crossDomain:true,
async: false,
contentType: "application/json; charset=utf-8",
success: function (response) {
$("#Content").text(response.d);
console.log(response.d);
},
failure: function (response) {
alert(response.d);
console.log(response.d);
}
});
Web Method 网络方法
[System.Web.Services.WebMethod]
public static string GetLocationPolygon(string location)
{
return location;
}
You can debug on server side as 500 internal error raised at server side only. 您只能在服务器端进行调试,因为仅在服务器端会引发500个内部错误。 You can catch and log the exact exception.
您可以捕获并记录确切的异常。
try this code 试试这个代码
$.ajax({
type: "POST",
data: JSON.stringify({"location":"aabb"}), //Change here
dataType: 'json',
url: url,
crossDomain:true,
async: false,
contentType: "application/json; charset=utf-8",
success: function (response) {
$("#Content").text(response.d);
console.log(response.d);
},
failure: function (response) {
alert(response.d);
console.log(response.d);
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.