Jquery ajax 调用 asp.net webservice 一般步骤

一般调用Web服务的步骤:

1.Web服务一定要添加[ScriptService]


  1)添加引用:System.Web.Extensions;
  2)using System.Web.Script.Services;

2.web.config中添加

<httpHandlers>
      <remove verb="*" path="*.asmx"/>
      <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </httpHandlers>

 

3.jquery调用时需要指明格式:

contentType:"application/json"
  dataType:"json"

无参数时,需要以下方式来传递
   data:{}

4.想要远程访问服务器上的webService还要在web.config的<system.web></system.web>中间加入如下配置节内容:

<webServices>
         <protocols>
            <add name="HttpSoap"/>
            <add name="HttpPost"/>
            <add name="HttpGet"/>
            <add name="Documentation"/>
         </protocols>
</webServices> 

 

posted @ 2013-03-23 16:48  Seaurl  阅读(167)  评论(0编辑  收藏  举报