【发布时间】:2016-03-08 19:08:39
【问题描述】:
我有一个类似{{0,0},{1,1},{2,2}} 的数组,它是一个javascript 变量。我尝试使用 JSON.Stringify 发布它,但它给出了内部服务器错误 500。我该如何发布和使用它?
这是我的 jquery 代码:
$.ajax({
type: "POST",
data: myJsonData,
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;
}
【问题讨论】:
-
如果错误是内部服务器错误,您应该检查您的服务器日志,看看发生了什么故障。
-
正如@user3663216 所说,您正在使用对象表示法,将您的代码或
myJsonData更改为有效数组。
标签: javascript jquery .net json ajax