login.aspx.csAsp.net邮政JSON
[System.Web.Services.WebMethod]
public static string jQueryPageMethod(string name)
{
return "<h3>jQuery - PageMethod </h3>result" + name;
}
JS/jQuery的:
如果我运行下面的方法,它的工作原理。
$.ajax({
type: 'POST',
url: 'login.aspx/jQueryPageMethod',
data: '{ "name":"exampleValue" }',
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function(result) {
alert("success");
},
error: function() {
alert('error');
}
});
如果我运行下面的方法它不工作。
var somevalue = "Value";
$.ajax({
type: 'POST',
url: 'login.aspx/jQueryPageMethod',
data: '{ "name":' + somevalue + ' }', // Problem here
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function(result) {
alert("success");
},
error: function() {
alert('error');
}
});
其中i在第二示例错过数据的一部分?
你能否更详细地解释什么是你正在尝试做? – Dana 2015-02-09 13:58:30
你能提供你所得到的错误吗? – 2015-02-09 13:59:18
我想发布值为jQueryPageMethod命名方法 – Soner 2015-02-09 14:04:11