标签:
一、
public function add(){ $this->display(); }
public function ajaxSave(){
if(IS_AJAX){
echo ‘执行输入‘;
$model = M("tb_user");
$model->create();
$model->add();
echo ‘执行成功‘;
}
}
view中
add.html
<!DOCTYPE html>
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="__ROOT__/Common/jquery-1.8.3.min.js"></script> //引入jqery
<script>
$(function(){
$("#subFrom").click(function(){
//3个参数 js中的jq 获取所有的值 串行化 回调函数
$.post("{:U("index/ajaxSave")}",$("form").serialize(),function(data){
alert(data);
})
});
})
</script>
</head>
<body>
<form>
<input type="text" name="name" />
<input type="text" name="like_num" />
<input type="text" name="hobby" />
</form>
<button id="subFrom">提交</button>
</body>
</html>
标签:
原文地址:http://www.cnblogs.com/rainblack/p/4728847.html