我正在尝试向我在Titanium中的Coutch db上的数据库发出请求。我已经尝试了下面的代码,但我得到了错误:无法检索数据。如果我尝试使用ex url http://www.appcelerator.com,,我可以获得数据。如果我使用coutch db url http://127.0.0.1:5984,我不能得到任何数据和错误。我想知道我是否应该使用另一个url?
var url = "http://www.appcelerator.com";
var client = Ti.Network.createHTTPClient({
onload : function(e) {
Ti.API.info("Received text: " + this.responseText);
alert('success' + this.responseText);
},
onerror : function(e) {
Ti.API.debug(e.error);
alert('error');
},
timeout : 5000
});
client.open("GET", url);
client.send();发布于 2014-04-18 05:10:20
您的CouchDB服务器运行在本地计算机上,您可以通过127.0.0.1或localhost访问它。
当你在iOS模拟器中运行你的代码时,你必须记住它是具有不同IP的虚拟环境。要进行从iOS模拟器到CouchDB的正确查询,您必须使用您的真实IP,您可以通过ifconfig命令检索到真实IP
ifconfig | grep inet | grep -v inet6 | cut -d ' ' -f 2发布于 2014-04-17 21:30:04
如果这个127.0.0.1是您的本地地址,那么您应该使用locallhost。
示例:
http://localhosthttps://stackoverflow.com/questions/23133495
复制相似问题