| Constructor | Description |
| PHPLiveX($functions) | Starts to handle ajax requests. Exports php functions for ajax.
$functions parameter: Optional. Its value is function names (if more than 1, seperated by commas); |
| Method | Description |
| Export("functionNames,...") | Exports the functions for ajax. Can only be called over run method.
Parameter Value: 1) Function names (if more than 1, seperated by commas). 2) "ALL" for all user defined functions. |
| ExportClassFunctions("objectName->methodName,...") | Exports class functions for ajax. Can only be called over run method.
Parameter Value: objectName (like myObject in "$myObject = new myClass();"). methodName is name of the class function. (if more than 1, seperated by commas); |
| ExportClass("objectNames,...") | Exports all functions of the classes for ajax. Can only be called over run method.
Parameter Value: Object names (if more than 1, seperated by commas); |
| Run() | Creates javascript codes to handle ajax requests. Must be called between script tags |
<?
function myFunction($text){
return $text;
}
$plx = new PHPLiveX("myFunction");
### OR
$plx = new PHPLiveX();
$plx->Export("myFunction");
?>
<?
class myClass(){
var $Text;
function myClass($text){
$this->Text = $text;
}
function setText(){
return $this->Text;
}
}
$test = myClass("it's very easy-to-use");
$plx->ExportClassFunctions("test->setText");
### OR
$plx->ExportClass("test");
?>
<script language="javascript"> <? $plx->Run(); ?> </script>
| Parameter | Description |
| type | Can take only one value "r". If you want to get returned value of the function (e.g. pass the value to a variable). And if this parameter is used, the others cannot be used. Note that if this parameter is used, the ajax request runs synchronously. (During the process, no other function runs.) |
| target | Takes the ID value of a DOM element and returned value of the function is printed to its innerHTML. If this parameter is used as "target=alert", the returned value is alerted. If it takes more values, these are given in this way: "target=id1:id2:id3". |
| mode | The default value is "rw"(rewrite) which means rewriting the value to the target. If you use "aw" (append), the value is appended to the initial content of target dom element. If you use "asw", the value is added before the initial content. |
| preload | Can take the ID value of a DOM element used for preload. It must be hidden(style="visibility:hidden") initially. During the process, the foregoing element is made visible and then hidden when the process finishes. Note that this parameter can not be used with type together. |
| method | Can take "post" and "get" values. These are the http-methods of the xmlhttp request. Default value is get. Added in version 2.1. |
| onFinish | The value must be the name of a js function. This function runs when the response of request is taken but before it is written to page. In addition, the response code is passed as an argument to the function. If it returns something, the response code to be written is replaced with this returned value. |
| onUpdate | The value must be the name of a js function. This function runs when the response of request is taken but after it is written to page. In addition, the response code is passed as an argument to the function. |
| hideContent | Can take 0 (default) and 1 values. "1" value means that during the preloading, the content of target dom element is emptied. | interval | Can take a time interval in milliseconds. With this interval, the function is called repeatedly. |
| myPreload | Provides users to create their own preloading systems. Two js function are written; one is called before the request and the other is called after the request. This property must be used in this way: "beforeRequestFunctionName:afterRequestFunctionName". |
<a href="javascript:myFunction('it is an example', 'target=showText,preload=loadSpan');">
test it</a>
<span id="showText"></span>
<span id="loadSpan" style="display:none;">Loading...</span>
<!--
Pay attention here!
Versions before 2.3 use "visibility:hidden" attribute but version 2.3 uses "display:none".
-->
<script>
function changeResponse(resp){
return "This text is added to returned value of myFunction. " + resp;
}
function showContent(resp){
alert(document.getElementById("showText").innerHTML);
}
</script>
<a href="javascript:
myFunction('It is another example',
'target=showText,preload=loadSpan,onFinish=changeResponse,onUpdate=showContent');
>test it</a>
<script language="javascript" >
var output = test__setText("an example", "type=r");
# ...
</script>