Cordova on iOS - AJAX call fails with {"readyState":"0", "responseText":"", "status":0,"statusText":"error"}

633 Views Asked by At

I updated cordova yesterday and added the iOS platform (cordova-ios@^6.1.0). I am trying to make an AJAX call via the XCODE simulator and it is failing with the following output:

{"readyState":"0", "responseText":"", "status":0,"statusText":"error"}

I installed cordova-plugin-whitelist plugin and added the following lines to config.xml:

<access origin="http://*" />
<access origin="https://*" />
<allow-navigation href="*" />

I have also added the following meta tag to the page:

Any help would be greatly appreciated!

1

There are 1 best solutions below

0
Kevin Lott On

Turns out the issue was with the server being called, a PHP API.

Adding the following allowed the AJAX request to succeed:

<?php

header("Access-Control-Allow-Origin: *");

?>