I am trying to make an AJAX call that will return me the echo of a php file, but it is not working... All the documents are in the same folder.
.html file (javascript part):
<script>
function GetData()
{
var xmlhttp;
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
return xmlhttp.responseText;
}
}
xmlhttp.open("GET","test.php",true);
xmlhttp.send();
}
var Order2 = GetData();
document.getElementById('Order2').innerHTML = Order2;
</script>
.php file:
<?php
echo "HELLO!";
?>
Does anyone know why this is not working? My browser is Google Chrome.
Thanks in advance :)