can a PhoneGap app access localhost upon being installed on device?

随声附和 提交于 2019-12-11 05:16:33

问题


I developed a test mobile app with PhoneJS, which access a node server ( localhost:3000) w MongoDB local DB... Everything is working fine when testing in web browser or using Ripple simulator.

Then I deployed this test app using PhoneGap/Cordova ( 3.0.0 ) and installed it on my iPhone device. Starting the app, the data are not loaded ( got the Loading icon... and nothing happen) As my node server doesn't display anything in the console, I guess there is an issue in the .get Ajax call

is there any specific parameter to be added to the PhoneGap config.xml ? ( I have already : github.com/erwin/DataBound.Mobile.git included ..


回答1:


Localhost is "this computer" so when you try to access localhost from your phone you don't get an answer because you don't have a server in your phone.

You have to use the local IP of the computer with the server instead using localhost if the server and the phone are on the same network



来源:https://stackoverflow.com/questions/19300135/can-a-phonegap-app-access-localhost-upon-being-installed-on-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!