Try This:
/** JAVA SCRIPT **/
// create a request query
var queryString = "?send_param=" + a;
// send request query to php file
xmlhttp.open("GET", "test.php" + queryString, true);
xmlhttp.send(null);
/** JAVA SCRIPT END **/
/** PHP SCRIPT **/
[ test.php ]
<?php
// if $_REQUEST array is empty show error and die;
if (empty($_REQUEST)) {
die("Error: No request found");
} else {
// split the $_REQUEST array and make array key as php variable
extract($_REQUEST);
}
/**
* Function testFun
* @param string $a
*/
function testFun($a)
{
// return val
}
// Call the function
testFun($send_param);
?>
/** PHP SCRIPT END **/
I preferred to use $.ajax function instead to Java Script Ajax, Coz it's handy :) and to good.
[1]: http://php.net/manual/en/function.extract.php