USING PHPLIVEX

<?

require("PHPLiveX.php");

function retrieveData($ID){
### Some codes getting and returning the value of a field depending on $ID from database.
return $field;
}

function updateDB($username, $email){
### Some codes updating a database with values of the arguments.
}

function getUserInfo($ID){
### Some codes getting and returning some information about a user depending on $ID from database.
return $information;
}

### You must first create the PHPLiveX object first. You may register your functions by entering them in an argument here optionally.
$plx = new PHPLiveX("retrieveData, updateDB");
### The other way to register functions for phplivex is to use export method. You can use it anywhere in the page.
$plx->Export("getUserInfo"); ### You are not obligated to use this method.

?>
<html>
<head>

<script language="javascript">
<? $plx->Run(); ?>
### You can use this method anywhere in the page between script tags. But it's better to use between head tags.

function printInfo(ID){

var info = getUserInfo(ID, 'type=r'); ### type=r means you get the returned value of the funtion
document.getElementById("content").innerHTML = info;

}
</script>
</head>
<body>

<a href="javascript:retrieveData(5, 'target=content,mode=aw,preload=prl');">Retrieve Data</a><br>
<a href="javascript:updateDB('mike', 'mk@blabla.com', 'preload=prl');">UpdateDB</a><br>
<a href="javascript:printInfo(10);">UpdateDB</a><br>

<div id="content"></div>
<span id="prl" style="visibility:hidden;" >Loading...</span>

</body>
</html>



As above, you must enter a last argument in your registered functions while calling. It can include some phplivex properties:
TYPE: It has one value "r". It's used when you want to get the returned value of the function. And if this property is used the others cannot be. TARGET: Its value is ID of the element where the returned value of the function is printed. MODE: Its default value is "rw"(rewrite) which rewrites the value to the target. If you use this as mode=aw (append), the value is appended to the initial innerHTML of target. PRELOAD: Its value is ID of the element used for preload. That should be hidden initially. During the process, the foregoing element is made visible and then hidden when the process finishes.
If you don't use any of this properties, leave the argument empty.