gpt4 book ai didi

jquery - Ajax 授权 header 尚未发送

转载 作者:行者123 更新时间:2023-12-01 03:50:10 25 4
gpt4 key购买 nike

我的 Ajax 授权 header 遇到一些困难。我尝试这样发送:

$.ajax({
url: query,
type: "GET",
accept: "application/json",
dataType: 'json',
beforeSend: function (xhr) {
alert('1');
var bytes = Crypto.charenc.Binary.stringToBytes("xxxxxxxx:xxxxxxxxx");
alert('2'+bytes);
var bas64 = Crypto.util.bytesToBase64(bytes);
alert('3'+bas64);
xhr.setRequestHeader("Authorization", "Basic " + bas64);
alert('up and awaaaaaaaay');
},
succes: function (result) {
alert('success!');
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.responseText);
//$('#DisplayInfoLoader').html('<span style="color: red;">An Error occured....' + xhr.responseText + '</span>');
//$('#DisplayInfoLoader').fadeOut(3000);
}
});

但是当我尝试代码时..它不会发送 header ...手动转到查询网址并填写凭据工作...甚至在 session 中使用凭据(/client GET 请求完美发送授权 header )访问/Project URI 时不会发送 header ....

最佳答案

解决方案是服务不允许使用 header 。浏览器会删除服务不允许的所有 header 。

确保服务使用Access-Control-Allow-Headers header !这就是我所学到的

关于jquery - Ajax 授权 header 尚未发送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9721473/

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