jQuery best way to block any other processes while waiting for Ajax completion -


This is

I have a registration form in the I domain text box field, people call the registrar API across domains in the domain for recognition on availability of domains.

Verification can take up to 15 seconds depending on the speed of the network.

In this waiting period, how to block if users click on submit button?

My idea is simple: before ending any Ajax call, I do not want to allow people to submit.

I can think in a way, but I'm not sure this is a good way. I need advice.

 Before : function () {$ ("# btn submit"). Attr ("disabled", "disabled"); }, Complete: function () {$ ("# btn submit"). Attri ("disabled", ""); } & Lt; Input type = "button" name = "submit btn" id = "submit btn" value = "my button" />    

Settings async to false It can work but it can hang the browser completely for 15 seconds. Your best bet is to disable the deposit element and stop it by using a variable in other ways, where you verify that in the verification process Is:

  var valid = false; $ (Function () {$ ('form'). Submit (function () {if (validating) return false; var button = $ (this). Find ('input: submit, input: button'); button.attr ('Disabled', 'disabled'); valid = true; $ .ajax ({url: 'validator.php', data: $ (this) .Serialize (), success: function () {validating = false; button RemoveAttr ('Disabled');}});});});  

In this way, the user can not submit the form to any other medium. If you disable the Submit button only, it may be possible to submit the form with the login key (not sure about this) using a variable that stops the verification that the verification is running to prevent accidental submissions There is a certain way of


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -