我有服务,当我称之为 我收到错误,预检的响应有无效的HTTP状态代码404,如下图所示。 请在这里解决这个问题 谢谢
这是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>
答案 0 :(得分:-1)
这对我有用:
var settings = {
"async": false,
"url": url,
"dataType": "json",
}
$.ajax(settings).done(function(response) {
$.each(JSON.parse(response), function(index, item) {
})
});