views:

205

answers:

1

I have a php form. After this form is submitted, if all data is valid, then it executes a python script which takes 5-10 seconds. For this wait period I would like to have a progress bar (.gif) displaying in the middle of the screen. If I could also 'fade away' the background so that the progress bar was like a top layer and the background a back layer, that would be great.

Thanks.

+2  A: 

Are you using any javascript libraries, such as jQuery? In any of the libraries, I'd imagine there'd be a dozen or so lightbox plugins floating about. Even if you don't want to use a library, you can take a look at their code, and instead of displaying a DIV, just display your gif, if you know what I mean.

There are even some plugins built specifically for this purpose, such as the BlockUI plugin for jQuery.


The basic algorithm for doing what you want goes like this:

  1. Start Ajax Request
  2. Display semi-transparent dark image over the whole page, with an animated gif in the middle.
  3. Listen for Ajax response
  4. Remove the overlay and loader gif.

I assume you already have steps 1 and 3 going alright. Step 4 is easy-peasy. Step 2 however isn't as easy, but still shouldn't be too hard. I couldn't tell you the code to do it myself, since I've just used lightbox plugins in the past. Take a look on Google for "simple lightbox" or something like that, since all you really want is the most basic functionality. This blog post talks about a CSS-only lightbox which would be a good starting point to help you style the overlay.

nickf
Thanks for your reply. The problem is that I am not familiar at all with Ajax... (shame on me). Therefore, I haven't 1 and 3 done. All I have done is the .gif I would like to use. I skimmed trough w3schools tutorial on Ajax, but didn't understand most of it. If you, or anybody else, could explained how I can use Ajax for this particular case, I would be very grateful. Thanks.
nunos
http://www.jquery.com <-- seriously.
nickf
I have already looked into that. but thanks for your help anyway.
nunos