I am designing javascript which can call php on a server (currently my own local computer)
Eventually, I will be using phonegap to interpret the javascript and display the results...
My problem seems to be connecting to the actual server.
Here's my javascript:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function loadXMLDoc() {
var xmlhttp;
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) {
document.getElementById("myDiv").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("POST", "http://127.0.0.1/myfiles/WorkingVersionVQuickLook.php", true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send("ipaddress=208.74.76.5");
}
</script>
</head>
<body>
<h2>AJAX</h2>
<button type="button" onclick="loadXMLDoc()">Request data</button>
<div id="myDiv"></div>
</body>
</html>
It works when instead of the localhost followed by the location, I reference just WorkingVersionVQuicklook.php like this:
xmlhttp.open("POST","WorkingVersionVQuickLook.php",true)
But once I add the exact location on the localhost it does not.
When I export to my emulator for Android, even the version that does work will not work on the emulator, which led me to the idea that I should specify its on the local machine. But because it does not even work when I do not run it via browser, it will not work on the emulator.
Please help me create a successfully mapped out connection so it will work for a browser, and then hopefully for my android!