Abhijit C Abhijit C - 1 year ago 71
Javascript Question

Show loading image

I am building a web application using

I am having a form the user clicks on submit button and I am processing the form and redirecting back to the same
I want to add the loading image so as the user can understand the request is being processed.
I tried my way by writing the script after the end of form tag and adding the image inside the form but not able to get it right on submission of form.
I am not using
, so the
is not useful for me.
Please can anyone help me in this.

Thanks in advance

<script type="text/javascript">
(function(d) {
d.getElementById('loginform').onsubmit = function () {
alert("on submit");
d.getElementById('submit').style.display = 'block';
d.getElementById('loading2').style.display = 'block';

Answer Source

I found a work around to see the loading image. Posting here so that other can be benefited.
I took a gif image and added it inside a div tag with css property display as block.

<div id="loading" style="position:absolute; width:100%; text-align:center; top:200px">
<img src = "images/loading.gif" width="70px" height="70px"/> </div>

Then I have written a javascript function which I call on event onload.In this function I am setting the display property to none.

function stopLoading()

In my case I am setting display block when I am sending any server request and onload the setting back to display none.
Hope this is helpful for others.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download