gpt4 book ai didi

javascript - iOS Firefox XMLHttpRequest 错误响应

转载 作者:行者123 更新时间:2023-11-28 06:24:13 25 4
gpt4 key购买 nike

我有一个函数可以发送 XMLHttpRequest GET 以从后端检索 JSON。

xhttp.onreadystatechange = function()
{
if(xhttp.readyState == 4 && xhttp.status == 200)
{
applicationUtil.showLoader(false);
if(handler != null)
{
alert(xhttp.responseText);
if(xhttp.responseText != "" && this.getResponseHeader('content-type') == "application/json")
{
handler(JSON.parse(xhttp.responseText), false);
}
else
{
handler("", true);
}
}
}
}

xhttp.open("GET", "../../csp/healthshare/hsanalytics/Custom.AMY.REST.Session.cls?CacheUserName="+ username +"&CachePassword="+ password, true);
xhttp.send(null);

现在,此功能在任何设备上的任何浏览器上都可以 100% 运行,接受 iOS Firefox。我尝试过使用 jQuery 路线,结果相同:

$.ajax({
url: "../../csp/healthshare/hsanalytics/Custom.AMY.REST.Session.cls?CacheUserName="+ username +"&CachePassword="+ password,
accepts:"application/json",
cache: false,
crossDomain: true,
dataType: "json",
username: username,
password: password,
error: function(event)
{
handler("", true);
},
success: function(data, status)
{
handler(data, false);
}
});

我花了几个小时研究该主题,但找不到任何针对我的问题的文章。

最佳答案

有些浏览器在 header 方面非常挑剔。您是否尝试过发送基本授权?包括用户名和密码..

例如)

{
"Authorization": "Basic " + btoa(username + ":" + password)
},

试试看:)

关于javascript - iOS Firefox XMLHttpRequest 错误响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35265894/

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