I'm developing a phonegap app for android and I need to be able to run the app on chrome. My app doesn't have any phone functionality yet. Is all Javascript, HTML and CSS.
The problem is I'm fetching some info of my server but I'm having trouble debbuging the javascript, so I wanted to test te app on the browser so I can use the developer tools, but the ajax call wont work on Chrome (It does on the phone).
Any ideas?
I'm developing a phonegap app for android and I need to be able to run the app on chrome. My app doesn't have any phone functionality yet. Is all Javascript, HTML and CSS.
The problem is I'm fetching some info of my server but I'm having trouble debbuging the javascript, so I wanted to test te app on the browser so I can use the developer tools, but the ajax call wont work on Chrome (It does on the phone).
Any ideas?
Share Improve this question asked Jan 6, 2012 at 16:48 Adrian MatteoAdrian Matteo 9871 gold badge10 silver badges28 bronze badges 03 Answers
Reset to default 5You need to run Chrome with the flag --disable-web-security
. You can either run chrome.exe --disable-web-security
from the mand line (in the appropriate directory) or edit the shortcut and add it. (Assuming you're on Windows)
If running in chrome is for testing only, jprofit's solution should be good enough. However, if users need to run it, they won't start chrome with those options :) In that case, you have two solutions
- Use JSONP ans script tags (this could be a lot of work and error handling is poor)
- Route your calls through a proxy on the local server http://developer.yahoo./javascript/howto-proxy.html, http://www.daniweb./web-development/php/code/216729
The simplest solution for me has been to use a proxy (as @juan-mendes suggests).
I use a tiny NodeJS server called Sleight, which runs locally ( http://phonegap./2010/01/20/introducing-sleight/ ).