【发布时间】:2012-04-17 08:18:09
【问题描述】:
我正在尝试调用外部站点 web 方法,并发布一些数据。我尝试了很多不同的方法,仍然无法获得要调用的方法。
这是我的js代码:
$.ajax({
url: "http://sitename.com/methods.aspx/mywebmethod",
data: "{'id':'" + 4 + "'}",
dataType: "jsonp",
type: "GET",
contentType: "application/json; charset=utf-8",
success: function (data) {
alert(data);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(errorThrown);
}
});
这是我的网络方法代码:
[WebMethod()]
public static bool mywebmethod(int id)
{
if(id != 0){
return true;}
else{return false;}
}
我总是得到同样的回应
Error: jQuery{code} was not called
我错过了什么?
【问题讨论】: