Alex Rivera | Logout

How to show a loading gif mean while a submit form is being executed JQuery

Asked 2011-11-15T18:03:50.270
12

I'm trying to show a simple spinner gif meanwhile a submit is being executed (it takes a bit because I have to establish some communications with providers via web services).

So, I have this:

$('#gds_form').submit(function() {
        var pass = true;
        //some validations

        if(pass == false){
            return false;
        }

        $("body").prepend('<div class="ui-widget-overlay" style="z-index: 1001;"></div>');
        $("body").prepend("<div id ='PleaseWait'><img src='/images/spinner.gif'/></div>");
        return true;
    });

the thing is, that the .gif doesn't show any animation, it's like it is frozen.

Why?

There's another way to implement this (notice that I'm not using AJAX and I don't want to)?

Thank you.

Edit
Report

1 Answer

0

I would the div on the page to start with, but with style='display:none' then stick a $('#PleaseWait').show() in your code when you want it to appear.

If you leave the display:none off you can edit see what it looks like without needing to submit the form again and again.

NB: you may want to wrap the overlay and the gif in a parent div for convenience.

answered 2011-11-15T18:10:02.747

Your Answer