本文介绍了jQuery的AJAX返回状态code 0同时要求跨域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图让跨域请求,但服务器可以与任何反应
i am trying to make cross domain request but server can not response with
Access-Control-Allow-Origin: *
我想读的响应头。当我试图读取状态code或待机状态则返回0。我的code为Ajax请求如下:
i am trying to read response header.when i am trying to read status code or ready state it returns 0. my code for ajax request is as follows.
$.ajax({
url: "https://accounts.google.com/o/oauth2/auth",
type: "POST",
data: {"response_type":"token","client_id":"6720XXXXXXX.apps.googleusercontent.com","redirect_uri":"http://localhost:51967/oauth2callback.aspx","scope":"https://www.googleapis.com/auth/calendar","state":"this is state information","approval_prompt":"auto"},
crossDomain: true
}).always(function(jqxhr,testStatus,errorThrown)
{
alert(jqxhr.readyState);
alert(jqxhr.status);
});
在此先感谢
推荐答案
您从Chrome浏览器在本地机器上测试?
Are you testing from Chrome on your local machine?
如果是这样,请参见 http://stackoverflow.com/a/10892392
这篇关于jQuery的AJAX返回状态code 0同时要求跨域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!