gpt4 book ai didi

javascript - Jquery Ajax 调用不设置 cookie

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:02:33 25 4
gpt4 key购买 nike

我检查了请求,可以看到:

Set-Cookie:.AspNet.Cookies=AQAAANCMnd8BFdERjHoAwE_Cl-sBAAAAFyzOzXtC90-nkj7osKIxHgAAAAACAAAAAAAQZgAAAAEAACAAAAB68msx5mvbIc_UOFEpHKgyKg8z4X75MKKk5Notp79FeAAAAAAOgAAAAAIAACAAAAD8G4ZvSLWFoqp7TVme89yuoX0Kd7V6uYe-WEeeSoYClvAAAAB1vGrXcVvzq7uUYiruKLJiGBpZJBDcOL3PBMRYnHv3VT202hC-4J-U-GGoJlWQz3MrEoq_vmEoE3tbsn09AAX06HZrhBl5ZvyLiTkCcJaAT_xeX-6Uv6fDWMHpezJ_xrhE8nVjOj8oBI2HhIjymzD1CaWCriFqPOQKSoC6OLOHurRUcZ6J8LHeKcsWsc4hm6z6VD-GgzHyHAzZ7OgHX6NMsBpkQ_6VX7e-lo-fUx4RG6sJRIKPHbbFGm8hpfNzFCffbS8nuGC7SMu9zoQLGdDcZx0ulxlQcSxpcfbaaPbb3l1FsM9YZOipQNyLRDQtN-5AAAAA2D6u3avm-yI1tnz-xqBLBus26s2IRF2vuBzDEFkTbG5PPYHY2ijq5-xMzkNlVNsgloQ-XjKhmy9JiX4YLkMSjQ%3D%3D; path=/; expires=Mon, 30-Sep-2013 21:49:58 GMT; HttpOnly

但是当我查看浏览器 cookie 时,这并没有设置。

$.ajax({
url: this.path + id,
beforeSend: (xhr) => this.setAuth(xhr),
type: 'GET'
})....

相关信息可能是它是跨源调用。 http://localhost:36859/http://127.255.0.1:8061/

我还需要做任何其他事情来设置 cookie 吗?

最佳答案

    return $.ajax({
url: this.path + id,
beforeSend: (xhr) => this.setAuth(xhr),
type: 'GET',
crossDomain: true,
xhrFields: {
withCredentials: true
}
}).fail((xhr, status, error) => {
console.log(arguments);
notification.showErrorMessage("Error Loading", notification.getErrorDetail(xhr));
});

xhrFields 成功了。身份验证 cookie 随 webapi 调用一起发送。

关于javascript - Jquery Ajax 调用不设置 cookie,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18837150/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com