html

首先在html文件中 绑定函数函数count({$v.id}) 出入一个id到下面的js脚本

<a href="{$v.url}" onclick="count({$v.id})"><img src="__PUBLIC__/FrontStyle/img/img_project/down.png" class="downimg2"></a>

js脚本进行请求给后天的

<script type="text/javascript"> function count(obj) { $.ajax({ url:"{:U('/Files/count')}", type:'post', dataType: 'json', data:{"id":obj} }); } </script>

PHP

Files/count的的函数中,后台获取到了前台的函数进行对数据库操作

public function count(){
    $map["id"]=$_POST["id"];
    $res=M("Files")->where($map)->setInc('pv',1);

}