Ajax call not deal with the issue of webService

Write a webService as the background and then the foreground with ajax call, no matter how errors are reported to abort the call. Then start troubleshooting the error.

1, copy the code before the project can already be called normal, paste over, and then put the address into the address now found an error abort. On the note is a background issue.

2, copy the code behind to try before normal operation of the above background, and then address webService prior to calling through this interface, you can find a normal call, indicating that this is a new webService problem.

3, then by comparison, in the new webService, we should add some configuration to be able to be called normal, otherwise you will have to error.

4, the following modifications web.config file <system.webServer>, add the following disposed inside, can be called normal.

<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="*" />

5, additional full configuration

<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>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules>
      <remove name="ApplicationInsightsWebTracking"/>
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"
        preCondition="managedHandler"/>
    </modules>
  </system.webServer>

 

Guess you like

Origin www.cnblogs.com/masha2017/p/11234096.html