score:1

Accepted answer

Since I have Access-Control-Allow-Credentials: true in Response header, I add xhrFields: { withCredentials: true } in $.ajax, and the cookies finally could be set.

Source code as following:

req:function(url, type, data,callback){
    var path = sys.SERVER_BASE;
    $.ajax({
        type : type,
        url : path + url,
        dataType : "json",
        data:data,
        xhrFields: { withCredentials: true },
        success : function(data){
            if(callback)callback(data)
        },
        error:function(data){
            if(callback)callback(data)
            console.log('fail');
        }
    });
},

Related Query

More Query from same tag