Drawbacks of using jQuery to cycle through images on a website
<p>I've created a comics website, <a href="http://www.hittingtreeswithsticks.com/" rel="nofollow">http://www.hittingtreeswithsticks.com/</a>, where if you click on a comic thumbnail it will take you to the full size of the image (the viewimage.php template).</p>

<p>On the viewimage.php template, I'm using javascript/jquery to cycle through images I've stored in an array so that users will not have to reload the page each time.</p>

<p><strong>There seems to be two problems with this:</strong></p>

<p>1) I also have a "like/dislike" feature I'd like to add... so that you can vote per image, as well as a facebook like button (so the user can like PER IMAGE). Currently, since jQuery is cycling through the images, it's not updating the id for that image you clicked on. (In this image, if I press right arrow key to go next, the id should increment to 35). </p>

<p><img src="http://i.stack.imgur.com/Q39s1.jpg" alt="enter image description here"></p>

<p><img src="http://i.stack.imgur.com/EG2UN.jpg" alt="enter image description here"></p>

<p>2) Eventually I'd like to make money off of Ad Revenue. Sources say that if I use jQuery to get the next image, instead of reloading the page, the Ad won't be refreshed... and I'll generate a lot less ad revenue. </p>

<p>So, my question is... is it possible for Jquery to handle these issues, or do I have to do page refreshes to increment the IDs and refresh the Ads?</p>

<p>Thanks!</p>

<p>EDIT: I've added in </p>

<pre><code>window.history.pushState(null, null, 'http://www.hittingtreeswithsticks.com/?action=viewimage&amp;site=comics&amp;id=imgIndex');
</code></pre>

<p>Code (this doesn't seem to  be working, and in fact blocks the "next" code from working)</p>

<pre><code>    $("#next").click(function() {
        imgIndex++;
            if (imgIndex &gt; imgArray.length-1) 
            {
                imgIndex = 0;
            }
            img.src = imgArray[imgIndex];
            window.history.pushState(null, null, 'http://www.hittingtreeswithsticks.com/?action=viewimage&amp;site=comics&amp;id=imgIndex');
    });
</code></pre>

<p>UPDATED:</p>

<p>Error: </p>

<p><img src="http://i.stack.imgur.com/qD2CM.jpg" alt="enter image description here"></p>
