当用户点击下载按钮时,向数据库+1,看到有方法在application/store/model/content.php里面已经有封装好的了,怎么在前端页面使用呢?我按下面这样写没有作用!
不会ajax不会js的我,搞不了,大神帮帮忙吧 该怎么写呢?
我这样写,调不到那个方法!
<a href="{$rs.url}" target="_blank" class="btn" id="downnum" rel="nofollow"></a>
<script type="text/javascript">
document.getElementById("downnum").onclick = function() {
addDownNum({$id})
};
</script>content.php的内容如下
<?php
namespace app\store\model;
use app\common\model\C;
use think\db;
//模型内容处理
class Content extends C
{
public static function addDownNum($id=0){
return Db::name('store_content2')->where('id',$id)->setInc('downnum',1);
}
}