AJAX vs PHP Directly into JS
<p>I have a little bit of a conundrum. Basically I'm developing a WYSIWYG Editor plugin for jQuery specifically for my web application. One of the features will be inserting an inline image tooltip based on the images a user has uploaded. For example:</p>

<pre><code>Hello there my name is [i="profile_pic.png"]A. Username[/i]
</code></pre>

<p>The part that I'm having an issue with is, when defining which images are available to a user, whether I should insert the PHP array directly into the Javascript like so:</p>

<pre><code>var available_images = "&lt;?=json_encode($User-&gt;Profile-&gt;images)?&gt;";
</code></pre>

<p>or to go for an Ajax GET that returns an encoded array of the image sources? I think the inline php makes more sense since it removes the need for an unnecessary ajax call but I didn't think that inserting inline php into javascript is terribly good form?</p>

<p>Any suggestions?</p>
