I want call a PHP function using Javascript(No Jquery)
MY php function is
<?php
function helloworld() {
echo 'Hello Ashish Srivastava';
}
?>
in hello.php file and my JavaScript is
<script type="text/javascript">
function getRoute() {
var hr = new XMLHttpRequest();
var url = "hello.php";
hr.open("helloworld", url, true)
hr.setRequestHeader("Content-type", "application/x-www-from-urlencoded");
hr.onreadystatechange = function()
{
if (hr.readyState === 4 && hr.status === 200)
{
var return_data = hr.responseText;
alert(return_data);
}
}
hr.send();
}
</script>
and HTMl is
<input type="button" value="Hello" onclick="getRoute()"/>
bt when i am calling this function i get nothing from server plz help