我正在使用Titanium,我必须向Couchdb发出HTTP get请求。这是我的代码:
var url ="http://192.168.0.152:5985/hello_world/00a271787f89c0ef2e10e88a0c0001f4";
var json;
var xhr = Ti.Network.createHTTPClient({
onload: function() {
Ti.API.info("Received text: " + this.responseText);
json = JSON.parse(this.responseText);
},
onerror: function(e) {
Ti.API.debug("STATUS: " + this.status);
Ti.API.debug("TEXT: " + this.responseText);
Ti.API.debug("ERROR: " + e.error);
alert('There was an error retrieving the remote data. Try again.');
},
timeout:5000
});
xhr.open("GET", url);
xhr.send();手术进入超时阶段。
发布于 2012-06-21 10:20:17
代码运行得很好。我用一个不同的URL测试了它。首先在web浏览器中检查URL以查看加载所需的量,然后增加超时值。如果工作正常,尝试在模拟器的浏览器中打开URL,您可能会发现这是一个IP问题
发布于 2012-06-21 16:26:19
这是couchdb中的ip问题;couchdb服务器侦听在127.0.0.1中。
https://stackoverflow.com/questions/11117223
复制相似问题