我设法设置了一个简单的web方法,我从jquery调用并确定它返回...然后我在方法上添加参数并将参数添加到jquery但是它出错了
Message":"Invalid JSON primitive: one.","StackTrace":"
我在网络方面的签名就是这样
[WebMethod]
public static string GetDate(string one, string two)
{
return "yes";
}
我的jquery是这样的,我做错了什么?
$.ajax({
type: "POST",
url: "MyService.aspx/GetDate",
data: { one: "value", two: "value" },
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
alert(msg.d);
},
error: function(msg) {
alert('error');
}
});
答案 0 :(得分:4)
尝试将数据参数括在引号中:
data: '{ one: "value", two: "value" }',