模版
【code】
<html>
<head>
<script src="__PUBLIC__/js/Base.js"></script>
<script src="__PUBLIC__/js/prototype.js"></script>
<script src="__PUBLIC__/js/mootools.js"></script>
<script src="__PUBLIC__/js/Ajax/ThinkAjax.js"></script>
<script>
function add(){
ThinkAjax.sendForm('frm','__URL__/ajax',wc,'result');
}
function wc(data,status){
if(status!=1){
alert('发送失败请检查');
}else{
$('list').innerHTML+='学生姓名'+data.sname+',性别'+data.sex+',年龄'+data.sage;
}
}
</script>
</head>
<body>
<div id="result"></div>
<div id="list"></div>
<form action="__URL__/ajax" method="POST" id="frm">
学生姓名<input type="text" name="sname"/><br />
性别<input type="text" name="sex"/><br />
年龄<input type="text" name="sage"/><br />
<input type="button" value="提交" οnclick="add()">
</form>
</body>
</html>
【、code】
控制器
【code】
public function ajax(){
$user =M('User');
if($vo = $user->create()){
if($user->add($_POST)){
$this->ajaxReturn($vo,'用户添加成功',1);
}else{
$this->errot(0,'添加错误',0);
}
}else{
$this->error($user->getError());
}
}
public function aja(){
$this->display('ajax');
}
【/code】