HTML snap code:
<div id='div'><img /></div>
jQuery code:
$("#div > img").click(function(){
var url = "path/to/img";
$(this).attr("src", url);
return false;
});
In Firebug I can see only one request,
but the img (from Firebug) is not the one displaying (from browser).
From my server, there are two requests.
Even if I set img src first, when clicked, it will still make two requests.
Having an image will cause a request made to the server to load its src. Changing its src will cause a request to be made for the new source.
Add the image to the document with JavaScript instead of having a placeholder there to start with.