Jquery – Show “Loading image” while page is loading

jquery

I'm far from good at jQuery, to start with. I have read these two questions that deal with the subject:

But I wonder how I can manage to show a "Loading text/image" when I press a link which is internal on my site? I have a link running a curl fetching function in PHP which take a while to be run.

The above example (links) deals with the subject if you have a Ajax function to it. Not just a link, which I wan't.

How am I able to accomplish this?

Best Solution

HTML

<a  href="someotherpage.php" >Your Link</a>

Script

$(function(){

  $("a").click(function(){
    $(this).after("<img src='loading_image.gif' alt='loading' />").fadeIn();  
  });

});

This code will add a loading image after each link when user clicks on that.

Working example : http://jsfiddle.net/YjWWX/3/

You can get some loading images from http://www.ajaxload.info