Phonegap No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access Phonegap No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access json json

Phonegap No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access


There should be no cross origin issue in phonegap/cordova as long as you configure properly access origin in config.xml.

It's normal that you have this message when testing from a browser if you miss some CORS headers.Try adding :

header('Access-Control-Allow-Origin: *');header('Access-Control-Allow-Methods: GET, POST');

But once again you don't need those headers for a phonegap app.

When you do echo "hi";, your're not sending json but sending a text "hi". (just writing json in the header does not format what you echo).

I think you should either use $.get in the javascript and remove header('Content-Type: application/json'); from php so that the app expects a simple text or modify your php to really send JSON.

for ex:

echo "{message:\"hi\"}";