I know this question has been asked many, many times online. I've run out of luck trying everything there is.
I'm trying to POST data to a server and get back a simple response. Obviously I would need to install the cordova whitelist plugin to achieve accessing external sources from the app, so I installed it.
The error I get back is: Failed to load resource: net::ERR_NAME_NOT_RESOLVED
Project Info:
- This is an Onsen UI app
- Cordova CLI 6.5.0
- Android Version 6.1.2
Installed Plugins:
- cordova-plugin-compat@1.1.0
- cordova-plugin-file@~4.3.2
- cordova-plugin-splashscreen@4.0.2
- cordova-plugin-camera@2.4.0
- cordova-plugin-whitelist@1.3.3-dev
Meta Tag:
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
Tools I'm using: Windows 10, Visual Studio 2015
What I have done:
Uninstalled and Reinstalled the Whitelist plugin, using Visual Studio
Uninstalled the plugin and reinstalled via Cordova CLI
cordova plugin add cordova-plugin-whitelist
Uninstalled and reinstalled plugin via Github
I've even updated Cordova to 6.5.0 from 6.2.0
I created a simple GET request to see if it works and still nothing works.
Cleared the Cordova Cache in Visual Studio.
Javascript code I used:
$http({
method: 'GET', url: "http://mywebsite.com/simple_get.php"
}).then(
function (response) {
alert(JSON.stringify(response));
},
function (response) {
alert(JSON.stringify(response));
}
);
jQuery Code also tried:
var settings = {
"async": true,
"crossDomain": true,
"url": "http://mywebsite.com/demo.php",
"method": "GET",
"headers": {
"content-type": "application/x-www-form-urlencoded",
"cache-control": "no-cache"
},
"data": {}
}
jQuery.ajax(settings).done(function (response) {
console.log(response);
});
I have no idea how to debug anymore and get to the problem, any help would be greatly appreciated... This is the final step for my app to be done :(
Thanks