/*前端 js代码*/
<script type="text/javascript">
jQuery(document).ready(function () {
$("a[ectype='clicknode']").click(function(){
var articleid = $(this).attr('name');
$.ajax({
url:"{:U('Article/ajaxclick')}",
data:"articleid="+articleid,
type:'post',
cache:false,
/*success:function(data){
alert(data);
}*/
});
})
});
</script>
<?php
/*文章控制器*/
namespace Home\Controller;
use Think\Controller;
/**
* 文章
*/
class ArticleController extends BaseController{
/*接收ajax请求,增加文章点击次数*/
public function ajaxclick(){
$map['id'] = I('articleid');
D('Article')->where($map)->setInc('view');
}
}