[英]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.
当我在设备上进行测试时,我的XmlHttpRequests不起作用,但是它们在模拟器和浏览器中都能正常工作。
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.
我是电话应用程序和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.
只是尝试一下,我关闭了eclipse,然后重新优化它以再次运行该应用程序,并且它起作用了。 I'm thinking eclipse needs to be restarted after a change to the config.xml file.
我认为在更改config.xml文件后需要重新启动eclipse。
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. 看一下这个问题: Android 4.1上的Access-Control-Allow-Origin错误 (不接受,但投票很高)答案可能可以解决问题。
There was an issue at cordova: https://issues.apache.org/jira/browse/CB-1101 科尔多瓦有一个问题: https : //issues.apache.org/jira/browse/CB-1101
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.