Each
AJAX applications interact between server and client browser on small parts of data. Even this data is small, user have to be informed about
progress of operation. For example, if no
progress bar or some animation are displayed while
AJAX application working, user will be not be informed whats happening.
For this, when you start interaction with the server it is good to inform the user, that the operation started and when work is finished, to stop the
progress bar and this makes user to feel, that the job is done.
For our example we will use already prepared
AJAX application of
MySQL PHP AJAX Query and will add some
Google-like progress bar.
Like you see, in application below, when you select an employ from the drop down list, now will appear small awaiting icon until the result is displayed:
In our
AJAX application we will use some
AJAX suitable animated GIF file for displaying "work in progress".
First, we have to set this gif file on suitable place around the <select> drop down, and to set him to be invisible. For this purpose we will use css
style="display: none;" property on the exact image and will assign some
id="tut_wait" for easy manipulating DOM object.
Next, in the beginning of our
AJAX function we have to set
document.getElementById('tut_wait').style.display='none';
AJAX Progress Bar image not to be
'none', actually to be visible.
When
AJAX function get done and data is received, our
progress bar have to hide. This happens by setting properties of
progress bar id:
document.getElementById('tut_wait').style.display='none';
In this example, server-side AJAX code (ajax.php) is the same like in the original version without AJAX progress bar. You can also get this file from here:
If you not fully understand all of this
AJAX Progress Bar Tutorial you can start with our
AJAX Basics tutorial or to look our
AJAX Tutorials section.