Reload background-image from PHP file using jQuery
<p>I have a <code>&lt;body style="&lt;?php include("gallery.php"); ?&gt;"</code> where gallery.php holds a random array of images, echoing the URL upon each reload.</p>

<p>I would like to have a button to refresh the background image of the body.</p>

<p>I currently am able to do one reload of the image, since the new URL is echoed.</p>

<p>EG:</p>

<pre><code>$(".refresh").click(function() {
    $("body").css("background-image", "url(&lt;?php include("gallery.php"); ?&gt;)");
});
</code></pre>

<p>But after the inclusion of the gallery file in the script, it is always the same url.</p>

<p><strong>EDIT</strong>
My PHP is as follows:</p>

<pre><code>$bg = array(
    array( "url" =&gt; "url_1" ),
    array( "url" =&gt; "url_2" ),
    ...
);


for ($i=0;$i&lt;1;$i++) {
    $id = array_rand($bg);
    echo "{$bg[$id]['url']}";
    unset($ad[$id]);
};
</code></pre>
