问题
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