I want to implement the comment function of the comment.
The image above is a capture of some of the following webtoon comments.
If you press "A" tag called "Reply 3", the comments are loaded down.
In my opinion, when you bring up this page for the first time, you even bring up the comments Rather, if you press the tag "A" called "Comment 3", it would be more efficient to call it up then I think so
I'm asking you a question because I can't think of a way to load it down without reloading when I press comment 3.
I'd appreciate it if you could explain it to a beginner and explain it in more detail!
comment
You can use AJAX. Below is a simple example.
<div id="comment">
This is also about the story...
<a href="#"onclick="reply_load()">View replies</a>
</div>
<div id="reply">
<!-- Reply loaded here -->
</div>
I organized the comments into a simple markup
#comment
is the comment part, and #reply
is the place to retrieve the reply later
When you open the page, just bring the comments to #comment
and leave them without anything in #reply
Pressing the tag here for reply view a causes an onclick event and executes the reply_load() function
function reply_load() {
// Get reply from server using ajax
$("#reply").append (processed and added the imported data to look good);
}
The reply_load function is described like this.
You need to make a part where you can get comments from the server
The value to be received in the part where you get the reply of the comment must be the unique number (id) of the comment stored in the DB. You can organize the query with that
I can't write down an example of the query because I don't know what the column is like now.
Anyway, you have to bring it and add it to #reply
The key keyword is jquery ajax. If you search on Google, you'll get a lot of examples.
© 2024 OneMinuteCode. All rights reserved.