Ajax實(shí)現(xiàn)phpcms 點(diǎn)贊功能實(shí)例代碼
首先 是將后臺(tái)中 模塊--->新聞心情--->心情配置 去掉多余的剩一個(gè),名稱改成 “贊” 提交保存。
其次 是修改新聞心情的模板文件:/phpcms/templates/default/mood/index.html
刪除所有代碼只返回點(diǎn)贊總數(shù)量
{loop $setting $k $v}
{$data[$v['fields']]}
{/loop}
模板頁(yè)面的實(shí)現(xiàn)如下 通過(guò)循環(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=mood&c=index&a=post&id=150-'+id+'-1&k=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ì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
相關(guān)文章
PHP Ajax實(shí)現(xiàn)頁(yè)面無(wú)刷新發(fā)表評(píng)論
PHP Ajax實(shí)現(xiàn)頁(yè)面無(wú)刷新發(fā)表評(píng)論...2006-12-12
解析ajax核心XMLHTTPRequest對(duì)象的創(chuàng)建與瀏覽器的兼容問(wèn)題
這篇文章主要介紹了ajax核心XMLHTTPRequest對(duì)象的創(chuàng)建與瀏覽器的兼容問(wèn)題。需要的朋友可以過(guò)來(lái)參考下,希望對(duì)大家有所幫助2013-12-12
asp+ajax實(shí)現(xiàn)靜態(tài)頁(yè)面分頁(yè)的代碼
asp+ajax實(shí)現(xiàn)靜態(tài)頁(yè)面分頁(yè)的代碼...2007-11-11
ajax提交到servelt獲取參數(shù)有亂碼的解決方法
這篇文章主要介紹了ajax提交到servelt獲取參數(shù)有亂碼的解決方法,需要的朋友可以參考下2014-02-02
重寫(xiě) ajax 實(shí)現(xiàn) session 超時(shí)跳轉(zhuǎn)到登錄頁(yè)面實(shí)例代碼
這篇文章主要介紹了重寫(xiě) ajax 實(shí)現(xiàn) session 超時(shí)跳轉(zhuǎn)到登錄頁(yè)面實(shí)例代碼,需要的朋友可以參考下2017-05-05
用AJAX實(shí)現(xiàn)頁(yè)面登陸以及注冊(cè)用戶名驗(yàn)證的簡(jiǎn)單實(shí)例
下面小編就為大家?guī)?lái)一篇用AJAX實(shí)現(xiàn)頁(yè)面登陸以及注冊(cè)用戶名驗(yàn)證的簡(jiǎn)單實(shí)例。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2016-10-10
Ajax獲取php返回json數(shù)據(jù)動(dòng)態(tài)生成select下拉框的實(shí)例
今天小編就為大家分享一篇Ajax獲取php返回json數(shù)據(jù)動(dòng)態(tài)生成select下拉框的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-08-08
Select2在使用ajax獲取遠(yuǎn)程數(shù)據(jù)時(shí)顯示默認(rèn)數(shù)據(jù)的方法
今天小編就為大家分享一篇Select2在使用ajax獲取遠(yuǎn)程數(shù)據(jù)時(shí)顯示默認(rèn)數(shù)據(jù)的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-08-08
ajax快速解決參數(shù)過(guò)長(zhǎng)無(wú)法提交成功的問(wèn)題
下面小編就為大家?guī)?lái)一篇ajax快速解決參數(shù)過(guò)長(zhǎng)無(wú)法提交成功的問(wèn)題。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2016-12-12

