Skip to content Skip to sidebar Skip to footer

Apache Cordova: Failed To Load Resource: The Server Responded With A Status Of 404 (not Found)

When I run my application either in the Android emulator or on my Android device, I get he following error on all AJAX requests: Failed to load resource: the server responded with

Solution 1:

Removing the whole Android part of the application with:

cordova platform remove android

and adding it again with:

cordova platform add android

solved the problem, which is still a mystery to me.

Perhaps there was something wrong left from the earlier versions of Cordova that wasn't getting on well with the current Cordova version.

Solution 2:

I think the problem's with your Content Security Policy meta tag - try adding * to the default-src to open up Ajax requests to anywhere. You could also add a connect-src clause specifically for Ajax requests and list the hosts and protocols you want to be able to access. For example:

<metahttp-equiv="Content-Security-Policy"content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *; connect-src http://myhost.mydomain.com">

Would allow Ajax requests to http://myhost.mydomain.com

I wrote a blog post addressing this topic that you may find helpful, it can be read here.

Solution 3:

Update Android

cordova platform update android@5.1.1

I had the problem for me connect to a php page on my server and I made an update to android

Post a Comment for "Apache Cordova: Failed To Load Resource: The Server Responded With A Status Of 404 (not Found)"