我在 windows 和 android 中都有 cordova sencha 应用程序,在 android sencha 上使用 XMLHttpRequest() 调用 http URL 时被拒绝,但它在 windows 上运行顺利
这是我的代码
var me = this,
xhReq = new XMLHttpRequest(),
this._errorCallback = errorCallback;
this._xhReq = xhReq;
xhReq.open("GET", source,true);
if (options && options.headers && options.headers.Authorization) {
xhReq.setRequestHeader("Authorization", options.headers.Authorization);
}
xhReq.responseType = "blob";
xhReq.onload = function () {
if (xhReq.status === 200 || xhReq.status === 0) {
} else {
errorCallback();
}
};
xhReq.onerror = function (e) {
logger.error("XHR download error occurred. status code = " + xhReq.status + " error msg = " + xhReq.statusText);
errorCallback();
};
xhReq.ontimeout = function () {
logger.error("XHR Timeout! status code = " + xhReq.status + " error msg = " + xhReq.statusText);
errorCallback();
};
xhReq.send(null);
它总是以错误结束,因为 http URL 在调用 https URL 时有效,有谁知道如何在 android 中强制使用 http URL,谢谢