Looks good .

Thanks will try to add that to my site and see how it goes.

Dave 

-----Original Message-----
From: Scott Sauyet [mailto:scott.sau...@gmail.com] 
Sent: January-12-10 6:06 PM
To: jQuery (English)
Subject: [jQuery] Re: Disable Submit

On Jan 12, 2:49 pm, "Dave Maharaj :: WidePixels.com"
<d...@widepixels.com> wrote:
> I have a form i am submitting via Ajax. So after submit while its 
> waiting for response i have my little spinner so user knows something is
happening.
> But how can i disable the submit while its "thinking" waiting for a 
> response so the user is not sitting there clicking submit over and over.

MorningZ's suggestion is good, but there is another approach that is always
worth considering for any long-running function that you don't want started
while it's already running.

    function myLongRunningFunc() {
        if (arguments.callee.running) return;
        arguments.callee.running = true;

        // your processing here

        arguments.callee.running = false;
    }

This is simpler than you need, if you have multiple forms to submit, so
you'd have to store the running flag in the form, not the function, but it's
not too hard to modify.

Here's a modification of MorningZ's page:

    http://jsbin.com/upilo (code http://jsbin.com/upilo/edit)

I think this is incomplete, because a form can be submitted in other ways
than by the click of a particular button, but some variation of this might
do.

It's not that I think this is a better solution than blockUI, but it's a
useful technique in its own right.

Cheers,

  -- Scott
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.725 / Virus Database: 270.14.130/2607 - Release Date: 01/12/10
04:05:00

Reply via email to