//ajax部分
$(function(){ $('#bm').click(function(){ var zhi = $('.ybm').html(); var pid = $('#pid').val(); $.ajax({ type:"post", traditional: true, url:"{:U('Home/Project/bm')}", data: {"zhi":zhi,"pid":pid}, dataType:"json", success:function(data){ $('.ybm').html(data); } }) }) });
//php部分
$data = $_POST; $zhi = $data['zhi'] + 1; $pid = $data['pid']; $user = M('project'); $k['click'] = $zhi; $user->where("pid = $pid")->save($k); echo $zhi;