Its pretty easy get the code from this site..
http://internetchampsonline.blogspot.in/2016/07/display-loading-icon-until-page-loads.html