Friday, 15 January 2010

cordova - Fetching cross domain XML in Phonegap 3.4 not function the same as working html webpage -



cordova - Fetching cross domain XML in Phonegap 3.4 not function the same as working html webpage -

i building android app using phonegap pulls news info xml file server , display them (using javascript) . programme works html webpage when in phonegap 3.4, the info des not display. suspect whitelist if xml file place in same folder phonegap works.

here code config.xml have tried:

<?xml version='1.0' encoding='utf-8'?> <widget id="io.cordova.hellocordova" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> <name>newspullapp</name> <description> sample apache cordova application responds deviceready event. </description> <author email="dev@cordova.apache.org" href="http://cordova.io"> apache cordova team </author> <access origin="http://testproject.com/*" subdomains="true" /> <content src="index.html" />

and

<?xml version='1.0' encoding='utf-8'?> <widget id="io.cordova.hellocordova" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> <name>newspullapp</name> <description> sample apache cordova application responds deviceready event. </description> <author email="dev@cordova.apache.org" href="http://cordova.io"> apache cordova team </author> <access origin="*"/> <content src="index.html" />

thanks looking through.

fine, application can reach out http://testproject.com or publicly available resource online in sec case.

but, server trying reach respond unknown origin? if didn't tell so, reply "no".

to tell so, must utilize cors (cross origin resource sharing). here's how to:

apache (in .htaccess or httpd.conf file): header set access-control-allow-origin *

php (before output):

note: using wildcard * not safe, allow attackers phone call script site , parse response.

phonegap load index.html file, , such, origin null. how safely perform operation in scenario beats me. if find out, please comment.

cordova

No comments:

Post a Comment