在ajax评论和喜欢的方框 [英] comment and like box in ajax

查看:76
本文介绍了在ajax评论和喜欢的方框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在我的网站上添加评论和类似的方框

解决方案

嗨朋友,



我发现你问的问题更多的是一个想法而不是任何代码,所以我也只会给你这样做的想法。在这种情况下,我不会提供任何代码,而且就像你自己的工作一样。



这是一个想法,



喜欢按钮:

1.喜欢按钮是一个简单的超链接

 <   a     class   =  like_button   < span class =code-attribute> href   = <?php echo 


post_id;?> > < <一样span class =code-leadattribute> / a >



2.每当a click事件发生在任何类似按钮上,你必须使用jQuery或javascript获取它的href属性。然后,您将使用AJAX将该值传递给处理器(一个php文件),该处理器将使用数据库连接来更新列'post_likes'WHERE'post_id'就是您发布给它的内容。



3.现在当处理器成功更新数据库时,它将返回true,javascript用它来更新前端的喜欢数量。



现在一个评论框:

1.再次概念是相同的,这次,而不是锚标记,你将有一个输入类型文本,它将包含类和一个名字

 <  输入    type   =  text    name   = <?php echo 

POST_ID; ?> class = comment_box / >



2.现在整个概念在返回键上都是相同的你可以搜索互联网用于检测javascript或jQuery中的RETURN键按事件检测。



3.现在这次,您可以将所有注释以序列化数组的形式存储在一个数据库表'posts'中的'post_comment'列。



4.步骤是,

 < span class =code-sdkkeyword> 


how to add a comment and a like box in my website

解决方案

Hi Friend,

I see the problem you have asked is more toward an idea rather than any code so I also will only be giving you the idea to do so. No code will be provided by me on this context and its like your own job to do so also.

Here's the idea,

Like Button :
1. A Like button is a simple hyperlink

<a class="like_button" href="<?php echo


post_id; ?>">Like</a>


2. Whenever a click event occurs on any like button, you have to get it's href attribute using jQuery or javascript. Then, you will use AJAX to pass that value to a processor (a php file) which will be using database connection to update a column 'post_likes' WHERE 'post_id' is what you have posted to it.

3. Now when the processor successfully updates the database, it will return true which is used by the javascript to update the number of likes on the front end.

Now a Comment Box :
1. Again the concept is same just that this time, instead of an anchor tag, you will have an input type text and it will contain class and a name

<input type="text" name="<?php echo


post_id; ?>" class="comment_box" />


2. Now the whole concept is going to be same about on return key press "you can search internet for detecting a RETURN key press event detection in javascript or jQuery.

3. Now this time, you can store all the comments in form of a serialized array in a single column 'post_comment' in database's table 'posts'.

4. The steps are,


这篇关于在ajax评论和喜欢的方框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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