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

Reply via email to