xajax简单例子,复制运行就明白了

<?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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值