Friday, January 25, 2013

Access-Control-Allow-Origin. issue on Phonegap JqueryMobile

When i ajax call to get or post some Data from Server, Some times I found error like below.

XMLHttpRequest cannot load file://localhost/Users/bhumika/Documents/phonegap-2.2.0/lib/ios/bin/****/www/js/data.json. Origin null is not allowed by Access-Control-Allow-Origin.

to Solve above error write below syntax in your device ready function.

$.support.cors = true;
$.mobile.allowCrossDomainPages = true;

Or  

Write Below syntax in PHP file to the server.
 
header('Access-Control-Allow-Origin: *');
Cheers....

No comments:

Post a Comment