Jquery无法调用webservice
function mytest() {
debugger;
$.ajax({
type: "POST",
contentType: "application/json",
url: "Service.asmx/CreateArray",
data: "{i:10}",
dataType: 'json',
success: function(result) {
alert(result.d);
},
complete: function(XMLHttpRequest, textStatus) {
//完成后要做的事情
alert(2);
},
error: function(x, e) {
alert(e.responseText);
//错误处理
}
});
}
webservice关键代码如下:
[System.Web.Script.Services.ScriptService]
....
[WebMethod]
public List<string> CreateArray(int i)
{
List<string> list = new List<string>();
while (i >= 0)
{
list.Add(i.ToString());
i--;
}
return list;
}
点击js事件没有任何反应,错误好像是无法找到webservice.asmx/CreateArray
不知道为什么会这样