23

I just updated my cordova version. When I run

cordova -v

It outputs version 5.0.0

On the older version of Cordova I had (I actually don't remember what version that was) I was able to use AJAX to request data from a given URL. However, after updating the Cordova version, it no longer works. I have made no edit to the code after this update, so I'm guessing something in the new Cordova version is preventing requests from going through.

I have added the following access grants in my config.xml file:

<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
    <allow-intent href="market:*" />
</platform>

but still no luck.

Has anyone come across a similar issue? Any idea how I can get it working again?

Thanks,

user3494561
  • 631
  • 5
  • 6

2 Answers2

40

Turns out I was just missing the following plugin:

cordova-plugin-whitelist

After I installed it, rm the android platform, re-added the android platform, build and run, it worked!

user3494561
  • 631
  • 5
  • 6
  • 1
    I updated to cordova 5.1.1, encountered the same issue, and this solved the problem. I really thought it was a certificate trust issue in the later android versions but this was the problem. Remember to add: `` to your _config.xml_ **EDIT**: formatting mistakes – Barryrowe Jun 29 '15 at 15:24
  • 1
    I didn't need to add any element to config.xml - once I added this plugin, everything started working again (I'm on cordova CLI 5.0.0). BTW - thank you much for this post - I had killed 4 hours by the time I found this. – Rick Mortensen Aug 04 '15 at 20:37
  • 2
    i'm using cordova v5.3.3, my app was working properly on Android 2.3.3 device without any issue. But when I tried on lollipop device, ajax calls were failing with "404" error. Finally installing the plugin saved my day! Thanks a lot. – Vinay Bhargav Nov 06 '15 at 13:15
0

Just remove the content of the meta tag in the index page <meta http-equiv="Content-Security-Policy">