I’m making a phonegap app and a chrome packaged app that needs to run locally most of the time, and occasionally receive data from my server as json.
I can’t figure out a single solution that will work on both platforms, while also working in development.
Originally i was getting padded json, and this worked fine for testing and with phonegap, but when i try to test my app as a chrome extension it fails due to what chrome is telling me are rules about inline javascript.
Due to failing in the chrome extension i changed all my ajax from jsonp to normal json.
Now, when i want to test things out, i usually navigate to the file:// location of the html page i want to test, but i can’t do any ajax from here.
Testing in chrome, it’s forbidden due to same origin policy stuff.
However, in production these methods seem to work fine.
Any suggestions on how to resolve this?
tl:dr: JSONP works on phonegap and file://, not chrome app
JSON works on phonegap and chrome app, not file://
Chrome Extensions do allow remote JSONP but only through a HTTPS connection. Check out the CSP (Content Security Police), specially it’s “Relaxing the default policy” session.