我肯定的犯一个非常蹩脚的错误,但无法弄清楚哪里...不能得到Web服务响应
这里是我的Web方法
[WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public int Add(int x, int y) {
return x + y;
}
和IM通过如AJAX调用它这
$.ajax({
type: "GET",
dataType: 'json',
contentType: "application/json; charset=utf-8",
data: { x: 4, y: 5 },
url: 'http://localhost:14436/Service1.asmx/Add',
success: function (data) {
alert('success');
var d = $(data);
console.log(d);
}
});
问题是我不能在success
得到返回的数据,
提琴手其显示{"d":9}
但我不断获取data
空...我做错了什么在这里... TIA
编辑
我的web服务是http://localhost:14436/Service1.asmx,并从我的web应用程序即时通讯访问网络服务位于http://localhost:3587/
所以我想这使得它跨域请求?
您已设置的contentType'“ application/json; charset = utf-8“'但你正在使用XML。 – 2011-03-17 08:21:41
仍然不起作用 – Rafay 2011-03-17 09:00:59