Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Browser State - Javascript/JQuery

I am trying to find a way to detect when my browser is loading and show a loading icon.

Also, is this the correct way to go about it or is there a 'standard' practice to accomplish something like that?

Edit: This functionality will be used for one of my sites during database transactions / table building.

like image 604
Geo Avatar asked Oct 21 '22 21:10

Geo


1 Answers

I like the JQuery loadmask plugin for this. Apply a mask over the element that is waiting to load some stuff (say via AJAX) on page load:

$('#containerid').mask("<img src='loadinganim.gif'/> Waiting...");

Waiting image

Then when everything is loaded and the user can interact with the element, remove the mask overlay (typically in a callback for an AJAX call after successful completion):

$('#containerid').unmask();
like image 177
mellamokb Avatar answered Oct 27 '22 09:10

mellamokb