Home>Article>Web Front-end> Ajax implements phpcms like function (graphic tutorial)

Ajax implements phpcms like function (graphic tutorial)

亚连
亚连 Original
2018-05-22 16:14:15 1877browse

This article mainly introduces the example code of Ajax implementation of phpcms like function. It is very good and has reference value. Friends who need it can refer to it

First, add the module in the background--->News Mood--->Mood configuration Remove the redundant one and change the name to "Like" Submit and save.

The second is the template file to modify the news mood:/phpcms/templates/default/mood/index.html

Delete all codes and only return the total number of likes

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

The implementation of the template page is as follows. Through the loop array

展会现场人头攒动

2017-02-01

id="zans{$r[id]}" title="$r[id]}">0

ajax processing K=8 is likes

$(".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; } }) });

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

Detailed analysis of how to use AJAX (code pasted)

phpajaxh5 implements the image upload function

phpajaximplements the query drop-down content function

The above is the detailed content of Ajax implements phpcms like function (graphic tutorial). For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn