I am seeking help for a question I posted on the community phoneGap web site:
http://community.phonegap.com/nitobi/topics/my-phonegap-app-cannot-access-my-web-service?rfm=1
But basically to sum it up I am slowly testing the waters with my phoneGap app, and I want to access a JSON file on my server and parse it and alert it out in my app. So far I cannot get this to work.
Things I have tried: 1) in my config.xml file in my phoneGap files I have the following tag: access origin="http://104.236.6.175" subdomains="true"
2) multiple different ways to access the JSON file with JavaScript, but currently this is my code:
$("#requestJSON").click(function () {
var xmlhttp = new XMLHttpRequest();
var url = "http://104.236.6.175/test/test1.json";
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var myArr = JSON.parse(xmlhttp.responseText);
myFunction(myArr);
}
}
xmlhttp.open("GET", url, true);
xmlhttp.send();
function myFunction(arr) {
var out = "";
var i;
for(i = 0; i < arr.length; i++) {
out += '<a href="' + arr[i].url + '">' +
arr[i].display + '</a><br>';
}
alert(out);
$("#resultLog").html(out);
}
});
Any help is much appreciated. Thanks.