Home  >  Article  >  Backend Development  >  如何利用ajax实现赞

如何利用ajax实现赞

WBOY
WBOYOriginal
2016-06-20 12:38:08965browse

在php+mysql 实现赞的方法很简单,每点击一次赞,传入字段(cont_id,cont_type),每次向数据库中like_count自动加1,但是如何利用jquery中的ajax实现呢?


回复讨论(解决方案)

$.ajax({  type:"get",  url:"xxxxxxxxxxxxxx.php",  data:{    action:"dianzan",   //php辨识ajax的标志(这一条不一定要加,看PHP文件结构    uid:"xxxxxxxxxxx",   //谁发起了点赞,    pid:"xxxxxxxxx",     //什么元素被点赞  },  success:function(msg){    //接收PHP返回的信息,是否点赞成功,如果成功,前台JS进行特效转换来提醒用户点赞成功  如果未成功则提示原因等等  }});

建议直接看视频教程
http://www.php100.com/html/shipinjiaocheng/PHP100shipinjiaocheng/2011/0417/7924.html

看了包会

楼上两位都是好人

楼主做出来了吗?可以给我具体的代码参考参考吗?

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