Phonegap Cordova Ajax requests 404 (Not Found) Error

天大地大妈咪最大 提交于 2019-11-27 18:05:35
Derek Arends

I had the same issue and had to install the cordova-plugin-whitelist

cordova plugin add cordova-plugin-whitelist

Credit goes to this stackoverflow article - Ajax Command to request URL no longer working

It should actually add the cordova whitelist plugin :

cordova plugin add cordova-plugin-whitelist

or in your config.xml file :

<plugin name="cordova-plugin-whitelist" spec="1" />

but if you are using the online phonegap build service the syntax is different. You have to add the following line in your config.xml file :

<gap:plugin name="cordova-plugin-whitelist" source="npm" />

and authorize cross domain requests :

<access origin="*" />
<allow-intent href="*" />
<allow-navigation href="*" />

This is not recommended because a wildcard is used everywhere and everything is permitted. But it is perfect for your tests.

This worked for me. The only difference is in my config.xml I had to put it in an node for it to take effect.

My example below:

<platform name="android">
    <allow-intent href="market:*" />
    <access origin="*" />
    <allow-intent href="*" />
    <allow-navigation href="*" />
</platform>

Phonegap User. Adding this line into the config.xml is the solution for me:

<gap:plugin name="cordova-plugin-whitelist" source="npm" />
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!