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
不知道为什么会这样

解决方案 »

  1.   

    查了很多资料都是那样写的啊,web.config也配置了:
    <webServices>
            <protocols>
              <add name="HttpGet"/>
              <add name="HttpPost"/>
            </protocols>
          </webServices>
      

  2.   

    webservice.asmx
    这个文件的路径错了。
      

  3.   

    web services ulr要写成这样:
    http://机器名:端口/虚拟目录/接口名,例如:http://localhost:2290/EmailService.asmx把你的web services拷贝到浏览器地址栏,如果能正常访问,说明就web services是没问题的。