AJAX和JS for LIKE按钮 [英] AJAX and JS for LIKE Button

查看:100
本文介绍了AJAX和JS for LIKE按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试学习如何制作AJAX脚本 在我的网站上单击喜欢"按钮.我有以下问题:

I'm trying to learn how make an AJAX script for a LIKE button, on my website. I have the following questions:

如果我要发送1个变量....id ..我这样做

if i'm sending 1 variable.... id.. I do this

data: "action=vote_up&id="+(this).attr("id")",

如果我要发送两个变量id和id1,这在语法上是否正确?

is this syntactically correct if i'm sending two variables id and id1 ?

  data: "action=vote_up&id="+(this).attr("id")&id1="+(this).attr("id1")",

2)href属性有什么用? php页面还是AJAX?

2) What goes into the href attribute? The php page or the AJAX?

<a href =""><img scr="like.png"></a>

3)首先运行..php页面或AJAX. 4)我是否必须使用jQuery或Pure Javascript运行AJAX

3) which is run first.. The php page or the AJAX. 4) Is it mandatory for me to use jQuery or Pure Javascript for running AJAX

感谢您的时间和耐心.我最感激.

thanks for your time and patience. I most appreciate it.

推荐答案

<a href ="#"><img scr="like.png"></a>在该链接上放置onclick事件,并发出AJAX请求以增加计数,在成功响应更新计数上单击按钮.而您忘记了一件事情,应该保存该按钮的状态.因为一个用户可以访问您的站点并在其上单击1000次.

<a href ="#"><img scr="like.png"></a> put onclick event on that link, and make AJAX request` to increment count, on success response update count clicks on button. And you forgot about one thing, you should save the state of that button. Because one user can go to your site and click 1000 times on it.

这篇关于AJAX和JS for LIKE按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆