When adding a comment to a page I have the option of either using location.reload(true); or executing a large amount of JQuery to dynamically add a DIV to the page. I already have code for interpreting the comments on the page itself when it loads so to have to duplicate it in JQuery not only adds to code duplication and confusion but also means when I want to change how the comments are parsed I have to change it in the PHP aspect of things and the JQuery aspect. Is it worth it or should I just refresh the page?
When adding a comment to a page I have the option of either using
Share
My approach would be to submit the comment to the server, and get an XML response with the contained HTML you use to display the comments. With the XML response you can use jQuery to append the new comment to the thread.
That portion of HTML can be generated with PHP the same way you do when reloading the page.
That way, you only modify PHP code.