How can I make comments like on stackoverflow?
What I mean more specificly, I use php/mysql how would I add a comment without reloading the page, I know this is a simple process of using AJAX but when you post a comment on SO it also has the option to delete it right away, when I insert comments into my DB there ID number is auto increment, so my real question now is
After posting the comment, is the comment posted, just added to the page with some javascript to append the contents to the page
OR
Does it use AJAX to retrieve that comment you just posted and then display it on the page?
The reason I am wondering is because since my system uses auto increment ID then if I did it the first method which would be faster to just ad the contents I posted on submit but this method would not give me the ID which is needed to be able to delete the comment by ID number
Hope that makes sense
UPDATE I posted below what I think now after reading other post on here
I'm going to go out on a limb and say it's right in between the two. The content of the comment is just posted from what you typed...
...but the page waits to append your comment until the AJAX magic has occurred and the page has the ID of your new comment.
(that should read: Here's how I would do it if I were you...fast, lightweight, and functional)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With