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)文章
jquery ajax多次請(qǐng)求數(shù)據(jù)時(shí) 不刷新問(wèn)題的解決方法
下面小編就為大家?guī)?lái)一篇jquery ajax多次請(qǐng)求數(shù)據(jù)時(shí) 不刷新問(wèn)題的解決方法。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2016-10-10Ajax向后臺(tái)傳json格式的數(shù)據(jù)出現(xiàn)415錯(cuò)誤的原因分析及解決方法
ajax往后臺(tái)傳json格式數(shù)據(jù)報(bào)415錯(cuò)誤,什么原因?qū)е碌哪?,該怎么解決呢?下面腳本之家小編給大家?guī)?lái)了Ajax向后臺(tái)傳json格式的數(shù)據(jù)出現(xiàn)415錯(cuò)誤的原因分析及解決方法感興趣的朋友一起看看吧2016-10-10ajax實(shí)現(xiàn)三級(jí)聯(lián)動(dòng)的基本方法
這篇文章主要為大家詳細(xì)介紹了ajax實(shí)現(xiàn)三級(jí)聯(lián)動(dòng)的基本方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-02-02Ajax實(shí)現(xiàn)城市二級(jí)聯(lián)動(dòng)(一)
這篇文章主要為大家詳細(xì)介紹了Ajax實(shí)現(xiàn)城市二級(jí)聯(lián)動(dòng)的相關(guān)資料,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-02-02基于Ajax技術(shù)實(shí)現(xiàn)無(wú)刷新用戶登錄功能
這篇文章主要介紹了基于Ajax技術(shù)實(shí)現(xiàn)無(wú)刷新用戶登錄功能,非常不錯(cuò),具有參考借鑒價(jià)值,需要的的朋友參考下吧2017-01-01