I am currently developing a Cordova application that makes use of ajax. Everything works perfectly during debugging, but once I build the release version, I encounter this error:
{"readyState":0,"status":0,"statusText":"NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'https://sub.domain.tld'."}
I'm confused about the source of this issue. I have added all the necessary lines to the res/xml/config.xml file:
<access origin="*" />
<access uri="*" subdomains="true" />
<feature name="http://api.phonegap.com/1.0/network"/>
I have also included the permission INTERNET in the AndroidManifest file. Despite these steps, the error persists...
Additionally, here is my ajax call:
jQuery.support.cors = true;
$.ajax(
{
accepts: {
xml: "text/xml; charset=ISO-8859-1",
text: "text/plain; charset=ISO-8859-1"
}
, converters: {
"text xml": jQuery.parseXML
}
, type: "POST"
//, contentType: "text/xml; charset=ISO-8859-1"
, contentType : "application/x-www-form-urlencoded; charset=iso-8859-1"
, url: address
, async: false
, cache: false
, crossDomain: false
, data: msg
, dataType: "text"
, global: false
, ifModified: false
, username: this.params.server.login
, password: this.params.server.pass
, timeout: 500000
, beforeSend: function(jqXHR) {
jqXHR.overrideMimeType('text/xml;charset=iso-8859-1');
jqXHR.setRequestHeader("Access-Control-Allow-Origin", "*");
jqXHR.setRequestHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
jqXHR.setRequestHeader("Access-Control-Allow-Methods","POST, GET, OPTIONS, DELETE, PUT, HEAD");
}
}
)
I would greatly appreciate any assistance in resolving this issue.