Home  >  Article  >  Backend Development  >  Analysis on usage examples of php plug-in Xajax

Analysis on usage examples of php plug-in Xajax

黄舟
黄舟Original
2017-09-02 09:47:401106browse

This article mainly introduces in detail how to use the php plug-in Xajax, which has certain reference value. Interested friends can refer to it

Xajax is a PHP plug-in without refreshing or jumping to other Page, a technology that can interact with the backend database by clicking components, etc.

Xajax is a plug-in for php. If you want to use Xajax, you must first download a compressed package from its official website. The Internet speed is slow, so I also uploaded one for everyone (click to open the link: https://pan.baidu.com/s/1gfkY3mj Password: bcvu), and everyone chooses to download it.

After downloading xajax_0.5_minimal.zip, put the contents into the project directory you want to develop. For example, the author's project directory is C:\PHPnow-1.5.6\htdocs\myphp\xajax


##xajaxhello.php, xjaxreg.php, xajaxregsuc.php are pages developed by the author. They are placed here to illustrate the folder xajax_core, xajax_js file copyright. inc.php must be placed in the project directory. Do not try to create another folder and place the folder xajax_core, xajax_js file copyright.inc.php in it. This is theoretically fine, but an error occurs during the following operation.


For example, the following xajax helloworld code:



registerFunction("myfunction"); 
function myfunction($text){ 
 $orps=new xajaxResponse(); 
 $orps->alert("helloworld!"); 
 $orps->assign("p","innerHTML",$text); 
 return $orps; 
 } 
$xajax->processRequest(); 
$xajax->printJavascript(); 
?> 
 
 
 
 
xajax 

For example, if you create a new folder xajax, copy the folder xajax_core, xajax_js file copyright .inc.php is placed inside, even if you change the second line in the helloworld code above, change include 'xajax_core/xajax.inc.php'; to include 'xajax/xajax_core/xajax.inc.php';


An error will also be reported during actual operation, and the following dialog box will pop up:


The entire program cannot be run!


Therefore, be sure to place the folder xajax_core, xajax_js file copyright.inc.php under the project directory. Anyway, there are only three files.


Let’s explain the above helloworld code,



registerFunction("myfunction"); 
 
function myfunction($text){ 
 //指定动作 
 $orps=new xajaxResponse(); 
 //调用orps中的alert方法,弹出helloworld对话框 
 $orps->alert("helloworld!"); 
 //调用orps中的assign方法,指定id为p的p的内文本为传过来的text参数 
 $orps->assign("p","innerHTML",$text); 
 //以下是指定动作 
 return $orps; 
 } 
$xajax->processRequest(); 
$xajax->printJavascript(); 
?> 
 
 
 
 
 
xajax 

So the running result of this xajaxhello.php is:


When loading the page first, there is only one ok, and then when I click ok, it interacts with xajax, the helloworld dialog box pops up, and then sets the id to p The inner text of p is helloworld!

Click again to repeat this action.

The above is the detailed content of Analysis on usage examples of php plug-in Xajax. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn