Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery Ajax调用,为什么在网络活动中列出两个请求?_Jquery_Ajax - Fatal编程技术网

jQuery Ajax调用,为什么在网络活动中列出两个请求?

jQuery Ajax调用,为什么在网络活动中列出两个请求?,jquery,ajax,Jquery,Ajax,我使用beforeSend头选项(添加授权令牌)发送Ajax调用,运行良好,但我可以看到控制台中列出了2个请求 $.ajax('https://macMini.local:8000/Products', { type: "GET", cache: false, async: false, dataType: "json", beforeSend: function (xhr, settings){

我使用beforeSend头选项(添加授权令牌)发送Ajax调用,运行良好,但我可以看到控制台中列出了2个请求

    $.ajax('https://macMini.local:8000/Products', {
          type: "GET",
         cache: false,
         async: false,
         dataType: "json",
         beforeSend: function (xhr, settings){ 
             xhr.setRequestHeader('Authorization', 'Bearer ' + amplify.store( "tokens" ).access_token); 
          }
     })...
在dev浏览器控制台中,我看到:

 Request URL:https://macmini.local:8000/Products?_=1381768498131
 Request Method:OPTIONS
 Status Code:204 No Content
 ...
没有回应 及


对于JSON响应,ajax请求是从另一个域或端口发出的吗?在这种情况下,它是一个,浏览器将首先发送一个
OPTIONS
请求,以检查GET请求是否可以安全发送


通常,
GET
请求不会首先发送
OPTIONS
,但在这种情况下,可能是因为您设置了额外的头而发出了“”请求。

async:false
==失败!就是这样,我在开发模式下同时运行客户端和服务器(node.js w CORS)。。。谢谢你澄清这一点。。。
 Request URL:https://macmini.local:8000/Products?_=1381768498131
 Request Method:GET
 Status Code:200 OK
 ...