Json 使用Titanium.Network.createHTTPClient()向coutchdb发送HTTP-GET请求?
我试图向我在Tianium Studio中的Coutch db数据库发出请求。 我尝试了下面的代码,但我得到了错误:无法检索数据。 如果我尝试使用ex urlhttp://www.appcelerator.com,我可以得到数据。 如果我使用coutch db urlhttp://127.0.0.1:5984,我无法获取任何数据+错误。 我想知道我是否应该使用另一个urlJson 使用Titanium.Network.createHTTPClient()向coutchdb发送HTTP-GET请求?,json,titanium,couchdb,titanium-mobile,getjson,Json,Titanium,Couchdb,Titanium Mobile,Getjson,我试图向我在Tianium Studio中的Coutch db数据库发出请求。 我尝试了下面的代码,但我得到了错误:无法检索数据。 如果我尝试使用ex urlhttp://www.appcelerator.com,我可以得到数据。 如果我使用coutch db urlhttp://127.0.0.1:5984,我无法获取任何数据+错误。 我想知道我是否应该使用另一个url var url = "http://www.appcelerator.com"; var client = Ti.Netwo
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();
如果这127.0.0.1是您的本地地址,那么您应该使用locallhost 例如:
http://localhost
CouchDB服务器在本地计算机上运行,您可以通过127.0.0.1或localhost访问它 当您在iOS模拟器中运行代码时,您必须记住它是具有不同IP的虚拟环境。要从iOS模拟器向CouchDB进行正确的查询,您必须使用可以从ifconfig命令检索的真实IP
ifconfig | grep inet | grep -v inet6 | cut -d ' ' -f 2