I've been struggling to successfully send JSON data to an HTTP URL (although I was able to successfully send the same data to an HTTPS URL). These are my current settings: config.xml
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
AndroidManifest.xml
android:usesCleartextTraffic="true"
HTML Header
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'; img-src * data: 'unsafe-inline'; connect-src * 'unsafe-inline'; frame-src *">
<meta http-equiv="Content-Security-Policy" content="default-src * gap://ready file:; style-src 'self' 'unsafe-inline' *; script-src 'self' 'unsafe-inline' 'unsafe-eval' *">
<script>
$.ajax({
type: "GET",
url: url,
dataType: "jsonp",
jsonp: 'callback',
crossDomain: true,
async: true,
data: {
id: results.rows.item(i).id,
bolla: results.rows.item(i).bolla,
anno: results.rows.item(i).anno,
magazzino: results.rows.item(i).magazzino,
articolo: results.rows.item(i).articolo,
quantita: results.rows.item(i).quantita,
term: terminale
},
success: function (data) {
console.log(data)
},
error: function (xhr, textStatus, err) {
alert("readyState: " + xhr.readyState);
alert("responseText: " + xhr.responseText);
alert("status: " + xhr.status);
alert("text status: " + textStatus);
alert("error: " + err);
}
});
</script>
When using JSON, it returns devicereadystate=0
, and when using JSONP, it returns devicereadystate=4
with a Error 404 (even though the URL works correctly in a browser).