【发布时间】:2015-05-21 21:04:00
【问题描述】:
我在 Titan 中发出了一个简单的 GET 请求,似乎在 android 5.0 及更高版本中无法正常工作。这是我收到的控制台的响应。
[INFO]:状态:200,连接类型:GET
=> 安卓 5.0
{"source":{"password":null,"status":0,"username":null,"autoRedirect":true,"bubbleParent":true,"allResponseHeaders":"","location": "","autoEncodeUrl":true,"apiName":"Ti.Network.HTTPClient","responseXML":null,"validatesSecureCertificate":false,"readyState":1,"domain":null,"responseText":" ","responseData":null,"connectionType":"GET","statusText":null,"connected":false,"_events":{"disposehandle":{}}},"error":"握手 失败","代码":-1,"成功":false}
错误:“握手失败”
这是我使用的代码。
var url = "MY URL";
var loader = Titanium.Network.createHTTPClient();
loader.onload = function()
{
Titanium.API.info('Status: ' + this.status);
Titanium.API.info('ResponseText: ' + this.responseText);
Titanium.API.info('connectionType: ' + this.connectionType);
Titanium.API.info('location: ' + this.location);
};
loader.onerror = function (e) {
console.log(JSON.stringify(e));
console.log("ERROR: " + JSON.stringify(e.error));
};
loader.open("GET",url);
loader.send();
希望你能帮我解决这个问题。
【问题讨论】:
-
如果您使用的是 https:// url,该请求似乎在 Android 5.0 及更高版本中不起作用。我所做的是删除 S 并将其保留为 http,但这不是永久解决方案,因为可能存在需要 https:// 的 Web 服务
标签: android titanium appcelerator