mysql-Request PHP reply comment code

Source: Internet
Author: User
Just like Baidu Post-reply can be displayed below the content of the comments

Reply content:

Just like Baidu Post-reply can be displayed below the content of the comments

Take Segmentfault for example:
Landlord issued a problem, this question has multiple answers, in the database is a one-to-many relationship.
Each answer can have multiple replies and is a one-to-many relationship.
Question (id,user_id,question_content)
Answer (Id,question_id,user_id,answer_content)
Reply (id,answer_id,user_id,reply_content)

The problem ...
Direct Ajax, with CSS display on OK

Using AJAX, how to use Ajax, please Niang, probably the principle is
When clicked, the 回复 button is used AJAX to request the server,
Server this side receives the request, does the storage database, XXX and so on the corresponding operation,
Then go out and get all the relevant comments, make a JSON-formatted interface, and return
Then, using JavaScript, manipulate the JSON and add the data to the corresponding comment location.

Ajax with CSS display can

I can tell you the general idea.
Use Ajax like comment.php to send a request to add a comment, and if it returns a status of added success, append the comment to the bottom of the comment list, failing to handle the failure.

Suggest main, first with native JS implementation under Ajax, don't come up with a variety of libraries

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.