Cordova XMLHttpRequest cross-domain request



Hi ! I am trying to execute XMLHttpRequest to get information from mysql database. I whitelisted the domain (containing the php file that create the XML outpout) inside config.xml file from cordova, but it does not work. It Works well on the domain when code is fired from server but not from phone or simulator. Here is my code :



if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();}
else{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
xmlDoc=xmlhttp.responseXML;
for(var i=0; i < xmlDoc.getElementsByTagName("place").length; i++) {
var xmlName = xmlDoc.getElementsByTagName("name")[i].childNodes[0].nodeValue;
document.getElementById('name').innerHTML += xmlName +"<br>"
}
}
}
xmlhttp.open("POST","http://ift.tt/1zA5Wm6",true);
xmlhttp.send();


Thanks for helps !


No comments:

Post a Comment