Ajax implements phpcms like function (graphic tutorial)

亚连
Release: 2018-05-22 16:14:15
Original
1873 people have browsed it

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}
Copy after login

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

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; } }) });
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!