我有这个Json:
var datatosend =
{
moduleID: '1',
data: { SomeData: 'SomeValue' }
};
并将其发送到网络服务:
$.ajax({
type: "POST",
async: false,
url: SomeWebService,
data: datatosend,
dataType: 'json',
contentType: "application/json; charset=utf-8",
success: function (msg) {
elm.append(msg.d);
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.responseText);
alert(thrownError);
}
});
使用此功能我只是收到错误:
[WebMethod(EnableSession = true)]
public string SomeFunction(int moduleID, object data) {
//do something
}
任何解决方案?
答案 0 :(得分:1)
在服务器上:
public string SomeFunction(int moduleId, string data)
{
//do something
}
在客户端上,尝试将JSON.stringify用于您要发送的对象:
JSON.stringify(datatosend)