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
ajax http请求未在同一域上发送document.cookie_Ajax_Cookies_Request - Fatal编程技术网

ajax http请求未在同一域上发送document.cookie

ajax http请求未在同一域上发送document.cookie,ajax,cookies,request,Ajax,Cookies,Request,为什么我的ajax请求没有发送document.cookie?我在同一个域名上 这是我的密码: document.cookie = "test=test"; var query_url = 'http://example.com/dosomething'; $.ajax({ url: query_url, type: 'GET', xhrFields: {withCredentials: true}, success:

为什么我的ajax请求没有发送document.cookie?我在同一个域名上

这是我的密码:

document.cookie = "test=test";
  var query_url = 'http://example.com/dosomething';
    $.ajax({
        url: query_url,
        type: 'GET',
        xhrFields: {withCredentials: true},
        success: function(data){
            if(data === "OK") {
                //some code
            };

            if(data !== "OK") {
                //some code
            }

        },
        error: function(error){
                            console.log("===ERROR");
                            console.log(error);
                }, 

      });


在设置my document.cookie的路径后,我的ajax请求正在发送它!xhrfield不是必需的

document.cookie = "test=test; path=/";
(编辑): 我的前端URL是example.com/fe/app.html。后端运行在example.com/也许这就是我在cookie中需要“path=/”的原因