dojo中调用webservice方法
GetInfo为后台服务
[WebMethod]
public string GetInfo(string id)
{
try
{
return json;
}
catch { return null; }
}
前天调用方法
//读值
function initValue() {
var xhrArgs = {
url: "../../Services.asmx/GetInfo",
handleAs: "json",
headers: { "Content-Type": "application/json" },
postData: dojo.toJson({ "id": 1}),
load: function (respone) {
ShowValue(respone);
},
error: function (error) {
alert("初始化值:" + error.message);
}
};
dojo.xhrPost(xhrArgs);
}