Outputting data with JQuery & PHP
<p>I have a general question regarding quality of writing code ...</p>

<p>I'm working on website, that outputs data from MySQL with PHP and it is being called with <code>$.get() / $.ajax()</code> with jQuery....</p>

<p>Now my question is .. the data I´m exporting for example: an array of comments (from class Comments) for a specific post, and this array is being returned from PHP as a string with its HTML manipulation  (<code>return '&lt;div id="this-&gt;$data"&gt; this-&gt;$data&lt;/div&gt;';</code>) and with the JQuery manipulation, I´m adding all the comments as list elements or anything else to a specific html element.</p>

<p>Is it useful to do this? Or it is better to send the array in a variable to jQuery, and then work with its elements and make the dynamic html code directly in JavaScript/jQuery..</p>

<p>If that was confusing, is it better to generate the html code in PHP when returning /echoing, or to generate the html code in jQuery after receiving the core data from the php? </p>

<p>I know there are other methods like XML JSPN, I'm just asking here about the efficient with generating HTML to manipulate core data (example: Array or Core Json data)</p>
