简体   繁体   English

Android XmlHttpRequest上的Phonegap可在模拟器和浏览器中使用,而不是在设备上使用

[英]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.

相关问题 RouterLink 在浏览器中工作,但不能在模拟器或设备上工作 - RouterLink Works in Browser But Not on Emulator or Device Phonegap:我的Javascript代码可在浏览器上使用,但不能在Android模拟器或设备上使用 - Phonegap: My Javascript code works on browsers but it doesn't work on Android emulator or device Cordova 相机插件适用于模拟器,而不适用于 Android 设备 - Cordova camera plugin works on emulator and not on Android device webview日期选择器在Android模拟器中工作,但不在设备上? - webview date picker works in android emulator but not on device? Phonegap画布无法在Android上绘制,但在浏览器中可以正常工作 - Phonegap canvas not drawing on android but works fine in browser PhoneGap设备准备就绪,无法在ios中触发,但在android模拟器和涟漪图中可以正常工作 - PhoneGap Device ready not firing in ios but working fine in android emulator and ripple ui-sref在ionicview上不起作用,但在浏览器,设备和模拟器上起作用 - ui-sref not working on ionicview, but works on browser, device and emulator Ajax请求可在浏览器上工作,但不能在Android设备上工作 - Ajax request works on browser but not on Android device PhoneGap Build:如何在Android设备浏览器中打开外部URL? - PhoneGap Build: how to open external url in device browser on Android? Facebook登录在浏览器中工作正常,但在带phonegap的android上不起作用 - Facebook login works fine in browser but doesn't work on android with phonegap
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM