iOS Firefox XMLHttpRequest 错误响应
iOS Firefox XMLHttpRequest wrong response
我有一个函数,它发送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);
}
});
我花了几个小时研究这个主题,但我无法找到任何针对我的问题的文章。
有些浏览器在标题方面非常挑剔。您是否尝试过发送基本授权?包括用户名和密码。
例如)
{
"Authorization": "Basic " + btoa(username + ":" + password)
},
试一试,看看:)
相关文章:
- "所请求的名称已经作为不同类型的“”存在;HTTP 409响应错误
- 使用来自AngularJS的Web API JSON响应-错误:应为和数组,但得到了一个对象
- Json响应错误Json.parse:意外的数据结束错误
- AngularJs-$httpProvider.interceptors多重响应错误
- 使用ajax的ReCaptcha响应错误
- 节点服务器响应错误: process.nextTick(function(){throw err;});.
- 为什么我在使用 .then() 的 AngularJS 工厂中没有得到正确的响应/错误
- 在 MEAN Web 应用程序中,从 Express(服务器端)发送 HTTP 响应错误 403、500,未在 Angu
- E_UNKNOWN beforeCreate 和其他生命周期回调的响应错误
- 处理 HTTPS 文件响应错误
- 防止 Internet Explorer 中的“无响应”错误
- Backbone.sync 获取所有响应错误状态代码
- 如何防止“无响应”错误
- 收集后POST响应错误.插入NodeJS Mongo模块
- 处理来自多个来源的响应错误
- 在角度中,如果服务器响应{错误:'ok'},则$http去捕获
- Express BodyParser响应错误的请求,状态为400
- 发送ajax请求时获取响应错误
- Webdriver/FXDriver utils.js导致脚本无响应'错误
- worldweatheronline API响应错误