1
votes

I have services and when i call it
I get error, Response for preflight has invalid HTTP status code 404 as shown in below picture. please here me to solve this problem Thank you

enter image description here

Here is ajax

    $.ajax({
        url:url,
        type: "Get",
        async: true,
        contentType: "application/text",
        dataType: "json",
        cache: false,
        crossDomain: true,
        success: function (data) {

        }

        }
    });

Web.config

 <system.webServer>
 <httpProtocol>
      <customHeaders>
        <remove name="X-Powered-By" />
        <add name="Access-Control-Allow-Origin" value="*" />
        <add name="Access-Control-Allow-Headers" value="Accept, Content-Type, Origin" />
        <add name="Access-Control-Allow-Methods" value="GET, PUT, POST, DELETE, OPTIONS" />
      </customHeaders>
    </httpProtocol>
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="1073741824" />
      </requestFiltering>
    </security>
    <modules>
      <remove name="FormsAuthentication" />
    </modules>
    <handlers>
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <remove name="OPTIONSVerbHandler" />
      <remove name="TRACEVerbHandler" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
  </system.webServer>
1
i have same issue. have you solved this issue ? - Saurabh Yadav

1 Answers

-1
votes

This worked for me:

var settings = {
  "async": false,
  "url": url,
  "dataType": "json",
}

$.ajax(settings).done(function(response) {
  $.each(JSON.parse(response), function(index, item) {

  })
});