I want to change the source of an image and show a "Loading..." image while the target image is loading. I am doing the following:
$('#imageid').attr('src','loading.jpg');
$('#imageid').attr('src',path);
where path is the path of the target image. However, JQuery is carrying out both actions at once, and loading.jpg is never displayed. The same thing happens when using regular Javascript.
How can I make the first line take effect so that loading.jpg is displayed while the next image loads?