升级到科尔多瓦5.0之后,Ajax请求失败+ cordova-android@4.0 [英] Ajax requests fail after upgrading to Cordova 5.0 + cordova-android@4.0
问题描述
我最近升级到科尔多瓦5.0(和科尔多瓦的Android 4.0),从那时起,我的应用程序不再能够访问外部资源。
I recently upgraded to Cordova 5.0 (and Cordova Android 4.0) and, since then, my app can no longer access external resources.
我仍然有<获得原产地=*/>
config.xml中(如前),我还有&LT ;使用-权限的Android:名称=android.permission.INTERNET对/>
在AndroidManifest.xml中(如前),但Ajax调用被拒绝,并没有解释(以下简称textStatus参数是错误,在errorThrown参数为空,而xhr.state()返回拒绝)。
I still have <access origin="*" />
in config.xml (as before), and I still have <uses-permission android:name="android.permission.INTERNET" />
in AndroidManifest.xml (as before), but ajax calls are rejected with no explanation (the "textStatus" param is "error", the "errorThrown" param is null, and xhr.state() returns "rejected").
我验证过没有请求被击中的服务器上,所以会出现它被停止的Android,但日志没有给出任何解释为什么...
I've verified that no request is hitting the server, so it appears it is being stopped by Android, but the log doesn't give any explanation as to why...
我可以从Android浏览器访问URL的问题很好,只是没有从应用程序。
I can access the URL in question fine from the Android browser, just not from the app.
Ajax请求通过调用作出Backbone.sync的 Backbone.js的,最终调用jQuery的$。阿贾克斯()() 。我并没有改变有关如何调用时......刚刚升级科尔多瓦任何东西。
The ajax request is made via a call to Backbone.sync() of Backbone.js, which ultimately calls jquery's $.ajax(). I haven't changed anything about how the call is made... just upgraded cordova.
是否有新的要求/设置的网络请求,科尔多瓦5.0,或任何我需要从previous科尔多瓦的版本有何不同?
有谁知道一个方法可以让我得到更多的信息,为什么Android和/或科尔多瓦被拒绝请求?
Does anyone know of a way I can get more information as to why Android and/or Cordova is rejecting the request?
推荐答案
我找到了罪魁祸首下降到android@4.0.0科尔多瓦平台。现在需要新的科尔多瓦 - 插件白名单的插件。
I tracked the culprit down to the android@4.0.0 cordova platform. It now requires the new cordova-plugin-whitelist plugin.
它可以与安装
cordova plugin add cordova-plugin-whitelist
或通过添加
<plugin name="cordova-plugin-whitelist" spec="1" />
要的config.xml,然后将其上配置
to config.xml, and then it is configured with
<allow-navigation href="*" />
代替旧的,&LT;获得原产地=*/&GT;
标记
这是一个有点恼人的日志不吐了白名单拒绝错误信息不再当这样的问题出现(这将有救了我一吨一时间),但也许这会晚一点。
It's a little annoying that the log doesn't spit out the "whitelist rejection" error messages anymore when a problem like this comes up (that would have saved me a ton a time), but maybe that'll come later.
这篇关于升级到科尔多瓦5.0之后,Ajax请求失败+ cordova-android@4.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!