菜单

PHP plug-in Xajax use detailed explanation

2017年11月22日 - PHPer

Xajax is a technology that PHP does not need to refresh or jump to other pages, and can interact with the background database by clicking on components and so on

Xajax is a plug-in of PHP, in order to use Xajax, you must first download a compressed packet to its official website, due to the slow network abroad, I also uploaded to you a (click Open Link: https://pan.baidu.com/s/1gfkY3mj password: bcvu), you choose to download.

Download the xajax_0.5_minimal.zip, put the things inside to the project directory you want to develop, such as the author of the project directory is C:PHPnow-1.5.6htdocsmyphpxajax

Xajaxhello.php, xjaxreg.php, xajaxregsuc.php is the author’s own development page, here is to illustrate

Folder xajax_core, xajax_js file copyright.inc.php must be placed in the project directory, do not try to build a folder to handle

Folder xajax_core, xajax_js file copyright.inc.php placed inside, so that the theory is no problem, but the error in the operation below.

For example, the following xajax HelloWorld code:

<? PHP

Include’xajax_core/xajax.inc.php’;

$xajax=newxajax ();

$xajax-> registerFunction (“myfunction”);

Function myfunction ($text) {

$orps=new xajaxResponse ();

$orps-> alert (“HelloWorld!”);

$orps-> assign (“div”, “innerHTML”, $text);

Return $orps;

}

$xajax-> processRequest ();

$xajax-> printJavascript ();

&gt?;

<! DOCTYPE HTML PUBLIC, “-//W3C//DTD XHTML 1 Transitional//EN”, “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd” >

< htmlxmlns= “http://www.w3.org/1999/xhtml” >

< head>

< metahttp-equiv= “Content-Type” content= “text/html; charset=utf-8” />

< title> xajax< /title>

< /head>

< body>

< divid= “div” > < /div>

< buttononclick= “xajax_myfunction (‘Hello world’);” > ok< /button>

/body> <

< /html>

For example, you create a folder, xajax folder xajax_core, xajax_js file copyright.inc.php

Put it in it, even if you change the second line in the HelloWorld code above, and change the include’xajax_core/xajax.inc.php’

Include’xajax/xajax_core/xajax.inc.php’;

In the actual operation will also be wrong, pop-up the following dialog box:

The whole program cannot run!

Therefore, we must put the folder xajax_core, xajax_js file copyright.inc.php placed under the project directory, anyway, there are not many three files.

Let’s explain the HelloWorld code above,

<? PHP

Include’xajax_core/xajax.inc.php’;

The specified action / /

$xajax=newxajax ();

/ / equivalent to declare a xajax function myfunction

$xajax-> registerFunction (“myfunction”);

Function myfunction ($text) {

The specified action / /

$orps=new xajaxResponse ();

The alert / ORPs method calls, HelloWorld pop-up dialog box

$orps-> alert (“HelloWorld!”);

The assign / ORPs method calls, specify the ID div div in the text for the text parameter passed

$orps-> assign (“div”, “innerHTML”, $text);

The following is an action /

Return $orps;

}

$xajax-> processRequest ();

$xajax-> printJavascript ();

&gt?;

<! DOCTYPE HTML PUBLIC, “-//W3C//DTD XHTML 1 Transitional//EN”, “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd” >

< htmlxmlns= “http://www.w3.org/1999/xhtml” >

< head>

< metahttp-equiv= “Content-Type” content= “text/html; charset=utf-8” />

< title> xajax< /title>

< /head>

< body>

< divid= “div” > < /div>

<… –html part of the key here is that I’m going to call the xajax function myfunction, and the parameter is helloworld–>

< buttononclick= “xajax_myfunction (‘Hello world’);” > ok< /button>

/body> <

< /html>

So the xajaxhello.php runs as a result:

First, when you load the page, there is only one OK, then click OK, interact with xajax, pop up the HelloWorld dialog box, and then set the internal text of ID of div div as helloworld!

Repeat this action once again.

发表评论

电子邮件地址不会被公开。