1、web.config <configuration>节点下添加以下内容:
  <system.web>
   <webServices>
      <protocols>
        <add name="HttpGet"/>
        <add name="HttpPost"/>
        <add name="HttpSoap"/>
        <add name="Documentation"/>
      </protocols>
    </webServices>
  </system.web>
 
  <system.webServer>
    <httpProtocol>
      <customHeaders>
        <add name="Access-Control-Allow-Methods" value="OPTIONS,POST,GET"/>
        <add name="Access-Control-Allow-Headers" value="x-requested-with,content-type"/>
        <add name="Access-Control-Allow-Origin" value="*"/>
      </customHeaders>
    </httpProtocol>
  </system.webServer>
2.正确地编写webserivce的代码
 // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
     [System.Web.Script.Services.ScriptService]
 
3、 ajax访问WebService使用Post方式请求

相关文章:

  • 2022-02-07
  • 2022-02-07
  • 2022-02-07
  • 2021-06-15
  • 2022-02-17
  • 2021-08-25
  • 2021-10-05
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-15
  • 2021-11-05
  • 2021-12-31
  • 2022-01-01
相关资源
相似解决方案