跨域ajax命中错误,即使返回的状态为200
我正在发送跨域ajax请求,响应返回状态为200。我还看到请求到达了服务器 我的服务器中有以下内容:跨域ajax命中错误,即使返回的状态为200,ajax,cross-domain,Ajax,Cross Domain,我正在发送跨域ajax请求,响应返回状态为200。我还看到请求到达了服务器 我的服务器中有以下内容: context.Response.Headers.Add("Access-Control-Allow-Origin", "*"); context.Response.Headers.Add("Access-Control-Allow-Credentials", "true"); context.Response.Headers.Add("Access-Control-Allow-Methods"
context.Response.Headers.Add("Access-Control-Allow-Origin", "*");
context.Response.Headers.Add("Access-Control-Allow-Credentials", "true");
context.Response.Headers.Add("Access-Control-Allow-Methods", "GET, POST, DELETE, OPTIONS");
context.Response.Headers.Add("Access-Control-Allow-Headers", "*");
这是在客户端上:
$.ajax({
type: "POST",
url: this.SERVER + url,
data: data,
xhrFields: {
withCredentials: true
},
success: function (a, b) {
debugger;
alert("sdsd");
},error : function(a,b) {
debugger;
},
dataType: 'json'
});
这是来自chrome浏览器的请求
在firefox中,我得到一个错误:
已阻止跨源请求:同一源策略不允许读取位于的远程资源http://localhost:2000/PageHandler.ashx. 这可以通过将资源移动到同一域或启用CORS来解决。我的猜测是,由于您发送的是Access Control Allow Credentials标头,因此无法将*放在Access Control Allow Origin中。尝试将源代码指定为JavaScript客户端的源代码 我基于Mozilla开发者网络文档中的以下信息: origin参数指定可以访问资源的URI。 浏览器必须强制执行此操作。对于没有凭据的请求 服务器可以将*指定为通配符,从而允许任何原点 访问资源