问题
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
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:
This worked for me:
var settings = {
"async": false,
"url": url,
"dataType": "json",
}
$.ajax(settings).done(function(response) {
$.each(JSON.parse(response), function(index, item) {
})
});
来源:https://stackoverflow.com/questions/47252264/ajax-response-for-preflight-has-invalid-http-status-code-404