<?php
require_once("xajax/xajax.inc.php");
$xajax = new xajax();
$xajax->registerfunction("myfunction");
function myfunction($arg)
{
// do some stuff based on $arg like query data from a database and
// put it into a variable like $newcontent
//对参数$arg做一些诸如:从数据库中获取数据后定义给$newcontent 变量的基础把持
// instantiate the xajaxresponse object
//实例化 xajaxresponse 对象
$objresponse = new xajaxresponse();
// add a command to the response to assign the innerhtml attribute of
// the element with id="someelementid" to whatever the new content is
// 在响应实例中添加一个命令,用来将id为someelementid的innerhtml元素属性
// 变为任何新的内容.
$newcontent = "阿斯达所多风高放火".$arg;
$objresponse->addassign("iddd","innerHTML", $newcontent);
//$objresponse -> addAlert($newcontent);
//return the xml response generated by the xajaxresponse object
//返回由 xajaxresponse 对象所天生的xml 响应
return $objresponse->getxml();
//return $objresponse;
}
$xajax->processrequests();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<?php $xajax->printJavascript('/xajax/'); ?>
</head>
<body>
<div id="iddd" ></div>
<button οnclick="xajax_myfunction('2');" >提交 </button>
</body>
</html>
require_once("xajax/xajax.inc.php");
$xajax = new xajax();
$xajax->registerfunction("myfunction");
function myfunction($arg)
{
// do some stuff based on $arg like query data from a database and
// put it into a variable like $newcontent
//对参数$arg做一些诸如:从数据库中获取数据后定义给$newcontent 变量的基础把持
// instantiate the xajaxresponse object
//实例化 xajaxresponse 对象
$objresponse = new xajaxresponse();
// add a command to the response to assign the innerhtml attribute of
// the element with id="someelementid" to whatever the new content is
// 在响应实例中添加一个命令,用来将id为someelementid的innerhtml元素属性
// 变为任何新的内容.
$newcontent = "阿斯达所多风高放火".$arg;
$objresponse->addassign("iddd","innerHTML", $newcontent);
//$objresponse -> addAlert($newcontent);
//return the xml response generated by the xajaxresponse object
//返回由 xajaxresponse 对象所天生的xml 响应
return $objresponse->getxml();
//return $objresponse;
}
$xajax->processrequests();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<?php $xajax->printJavascript('/xajax/'); ?>
</head>
<body>
<div id="iddd" ></div>
<button οnclick="xajax_myfunction('2');" >提交 </button>
</body>
</html>