Possible Duplicate:
XmlHttpRequest error: Origin null is not allowed by Access-Control-Allow-Origin
I'm a newbie to JavaScript Phonegap and AJAX. Am trying to write a simple Phonegap app that will request for a message from a server however the app does not respond. When I run my script on chrome browser as a file because I understand that is how Phonegap works it shows the foll XMLHttpRequest cannot load http://localhost/mpl/getPage.php. Origin null is not allowed by Access-Control-Allow-Origin.
How can I fix this? My code is down below.
<html>
<head>
<script type="text/javascript">
function getMessage()
{
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("serverReply").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","http://localhost/mpl/getPage.php",true);
xmlhttp.send();
}
</script>
</head>
<body>
<div id="serverReply" onclick="getMessage();"><b>Get message</b></div>
</body>
</html>
My getPage.php
is simple it's just
<?php
echo 'cool';
?>
Pleas help me. Thanks.