在php上使用ajax返回值

I am trying to pass ajax response value to a php function.

ajax.js

 xmlhttp.onreadystatechange=function(){
  if (xmlhttp.readyState==4 && xmlhttp.status==200){
    var a = xmlhttp.responseText;
    }
  }

I need a value to be used in PHP function.

test.php

function testFun($a); 

Is this possible??? Thanks for the help!!

Write up another AJAX request and pass a into a PHP file containing the function and read the input as either GET or POST, then use the output as you see fit. Using a JS framework like jQuery will help shorten your AJAX calls.

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.