我有这样的代码:我使用数据值作为对象字面值,而不是连接字符串。为什么? see here消息:无效的JSON基元:使用c#的jQuery jQuery方法Webmethod
我的代码是这样的: -
$.ajax({
url: "../Member/Home.aspx/SaveClient",
type: "POST",
async: false,
dataType: 'json',
contentType: 'application/json; charset=utf-8',
data: {
"projectSoid": ProjectId,
"startDate": StartDate,
"endDate": EndDate,
"clientManager": ClientManager
},
success: function (response) {
if (response.d != "") {
}
},
error: function (response) {
var r = jQuery.parseJSON(response.responseText);
alert("Message: " + r.Message);
alert("StackTrace: " + r.StackTrace);
alert("ExceptionType: " + r.ExceptionType);
}
})
和的webmethod是这样的:
[WebMethod]
public static string SaveClient(string projectSoid, string startDate, string endDate, string clientManager)
{}
问题是我得到的错误是这样的:
消息:无效的JSON原始:projectSoid
您需要JSON.strigify数据:'数据:JSON.strigify({ “ projectSid“:ProjectId, ”startDate“:StartDate, ”endDate“:EndDate, ”clientManager“:Clien tManager }),' – nemesv 2013-03-08 12:18:33
对我的评论发表了评论?你试过了吗?它有效吗? – nemesv 2013-03-08 13:30:59
我不知道什么是JSON.strigify?我有错误,它不是功能:( – 2013-03-08 13:33:20