简体   繁体   中英

Phonegap on Android XmlHttpRequest Works in Emulator & browser, Not on Device

I'm stuck. My XmlHttpRequests are not working when I test on my device, but they do work perfectly in the emulator and in my browser.

Also I have added the domain to my whitelist. The really weird part is that it was working perfectly fine on the device yesterday too. Any ideas? I'm brand new to phone apps and phonegap.

<!--
    access elements control the Android whitelist.
    Domains are assumed blocked unless set otherwise
     -->

    <access origin="http://127.0.0.1*"/> <!-- allow local pages -->
    <access origin="http://*.mydomain.com" />Code not neede

-------------- edit ----------------

I'm not sure why, or what happened. After playing around some more I changed.

<access origin="http://127.0.0.1*"/> <!-- allow local pages -->
<access origin="http://*.mydomain.com" />

to

<access origin="*"/>

The problem still existed. Just to try it I closed eclipse and then re-opnened it to run the app again and it worked. I'm thinking eclipse needs to be restarted after a change to the config.xml file.

Take a look at this question: Access-Control-Allow-Origin Error At Android 4.1 The (not accepted but highvoted) answer may solve the problem.

There was an issue at cordova: https://issues.apache.org/jira/browse/CB-1101

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM