首先 是將后臺(tái)中 模塊--->新聞心情--->心情配置 去掉多余的剩一個(gè),名稱改成 “贊” 提交保存。
其次 是修改新聞心情的模板文件:/phpcms/templates/default/mood/index.html
刪除所有代碼只返回點(diǎn)贊總數(shù)量
{loop $setting $k $v}
{$data[$v['fields']]}
{/loop}
模板頁(yè)面的實(shí)現(xiàn)如下 通過循環(huán)數(shù)組
div class="info">
a target="_blank" title="展會(huì)現(xiàn)場(chǎng)人頭攢動(dòng)">h4 class="title ellipsis download">展會(huì)現(xiàn)場(chǎng)人頭攢動(dòng)/h4>/a>
p class="date">2017-02-01/p>
div class="sum">
span class="laud">i class="iconfont zanbtn" >贊/i>a href="javascript:;" rel="external nofollow" span style="min-width: 0px; min-height: 0px; box-sizing: border-box; color: rgb(34, 34, 34); unicode-bidi: -webkit-isolate; font-family: Consolas, "Lucida Console", monospace; white-space: pre-wrap;">id/span>span style="color: rgb(34, 34, 34); font-family: Consolas, "Lucida Console", monospace; white-space: pre-wrap;">="/span>span style="min-width: 0px; min-height: 0px; box-sizing: border-box; color: rgb(34, 34, 34); unicode-bidi: -webkit-isolate; font-family: Consolas, "Lucida Console", monospace; white-space: pre-wrap;">zans{$r[id]}/span>span style="color: rgb(34, 34, 34); font-family: Consolas, "Lucida Console", monospace; white-space: pre-wrap;">" /span> title="span style="color: rgb(34, 34, 34); font-family: Consolas, "Lucida Console", monospace; white-space: pre-wrap;">$r[id]}/span>">0/a>/span>
/div>
/div>
ajax 處理 K=8是點(diǎn)贊
$(".zanbtn").on("click",function(){
var id = $(this).next().attr("title");
var aval = $(this).next("a").html();
$.getJSON('http://phpcms.com/index.php?m=moodc=indexa=postid=150-'+id+'-1k=8'+Math.random()+'callback=?', function(data){
if(data.status==1) {
console.log( $(this).next());
$("#zans"+id).html(data.data);
}else {
alert(data.data);
return false;
}
})
});
以上所述是小編給大家介紹的Ajax實(shí)現(xiàn)phpcms 點(diǎn)贊功能實(shí)例代碼,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
您可能感興趣的文章:- php+mysql+ajax 局部刷新點(diǎn)贊/取消點(diǎn)贊功能(每個(gè)賬號(hào)只點(diǎn)贊一次)
- PHP+fiddler抓包采集微信文章閱讀數(shù)點(diǎn)贊數(shù)的思路詳解
- php+jQuery+Ajax實(shí)現(xiàn)點(diǎn)贊效果的方法(附源碼下載)
- php+xml結(jié)合Ajax實(shí)現(xiàn)點(diǎn)贊功能完整實(shí)例
- php+mysql結(jié)合Ajax實(shí)現(xiàn)點(diǎn)贊功能完整實(shí)例
- php+js實(shí)現(xiàn)點(diǎn)贊功能的示例詳解