亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Ajax實現phpcms 點贊功能實例代碼

 更新時間:2017年03月09日 11:27:22   作者:Young-楊培麗  
這篇文章主要介紹了Ajax實現phpcms 點贊功能實例代碼,非常不錯,具有參考借鑒價值,需要的朋友可以參考下

首先 是將后臺中 模塊--->新聞心情--->心情配置  去掉多余的剩一個,名稱改成 “贊” 提交保存。

其次 是修改新聞心情的模板文件:/phpcms/templates/default/mood/index.html

刪除所有代碼只返回點贊總數量

{loop $setting $k $v} 
{$data[$v['fields']]} 
{/loop} 

模板頁面的實現如下  通過循環(huán)數組

<div class="info"> 
          <a  target="_blank" title="展會現場人頭攢動"><h4 class="title ellipsis download">展會現場人頭攢動</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是點贊   

$(".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實現phpcms 點贊功能實例代碼,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網站的支持!

相關文章

最新評論