[英]I have internal server error 500 when I tried to post json in Jquery ajax
當我嘗試發送JSON JSON.stringify(coords); 或以上代碼,我會收到錯誤消息,但是我嘗試在數據為空時使用數據: 我怎么解決這個問題?
$.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);
}
});
網絡方法
[System.Web.Services.WebMethod]
public static string GetLocationPolygon(string location)
{
return location;
}
您只能在服務器端進行調試,因為僅在服務器端會引發500個內部錯誤。 您可以捕獲並記錄確切的異常。
試試這個代碼
$.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.