Jump to content

[SOLVED] Loading animation


Brandon Jaeger

Recommended Posts

Hey guys,

 

I've searched all over for hours now and I can't find an example anywhere...

 

I want to have a script for when the user hits the submit button in a form, it covers the whole page in a transparent color and displays a loading GIF in the middle (for 2-3 seconds), then disappears.

 

Does anyone know how to do that?

 

Thanks,

Brandon

Link to comment
Share on other sites

This can be done with just JavaScript and CSS.

 

Put this at the top of your HTML page:

<table width="100%" height="100%" bgcolor="#FFFFFF" cellpadding="5" id="pleasewait" style="display:none;z-index:1;position:absolute;left:0px;top:0px;">
<tr height="225">
	<td width="100%" colspan="3">
		 
	</td>
</tr>
<tr>
	<td width="49%">
		 
	</td>
	<td align="center" valign="middle" width="2%" nowrap bgcolor="#FFFFFF" style="border: solid 1px black;">
		Please wait...<br>
		<image src="images/pleasewait.gif">
	</td>
	<td width="49%">
		 
	</td>
</tr>
</table>

 

Then in your JS function that runs when you're calling your AJAX, just add this in the function:

document.getElementById('pleasewait').style.display = "block";

 

You may have to do a little more than that, but it should get you started. Also, I just posted something similar on another topic, and you can grab the peasewait.gif there:

http://www.phpfreaks.com/forums/index.php/topic,219292.0.html

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.