0

I have an sign in form in ASP.NET MVC 3

After clicking submit it is taking a bit time to submit the form because there is a lot of things taking place. as a result user may click the button once again thinking that something wrong and something very bad may happened.

So i just may enable/disable the button it is probably the easiest way to prevent second click, but i would rather change form post to ajax way.

Si what i am thinking to do: After user click submit i want to display popup/div saying that the request being processed and showing some kind of ajax lader there and after form being processed i want user to follow to the Action according with server controller logic(the client side doesn't know where user will be redirected.)

Is it possible to do ? What is you opinion? How can i do it better way?

Currently i am looking in to jQuery Form plugin may be it would help, but if you may suggest something it would be great.

Also just found this solution ajax - Prevent double click on submit but i think i still would like display popup with progress.

Community
  • 1
  • 1
Joper
  • 8,019
  • 21
  • 53
  • 80

1 Answers1

0

I have had the same issue, and in the past I have used the .attr("disabled","disabled") to disable the button on the first click, then the second click does not get triggered. In the success (or error) method of the JQuery ajax response use .removeAttr("disabled")

EDIT:

To add a pop-up you are normally just displaying a <div> and hiding it when processing is finished.

So by default you div CSS is

#myPopUp{
display: none;
top: 50px;
left: 50px;
width: 250px;
height: 100px;
background-color:darkblue;
background-color:white;     
}

HTML

<div id="myPopUp">This is a popup</div>`

now when you are adding the disabled to the button you can also display the pop-up with $("#myPopUp").show() and hide it again just after you do the remove disabled on the button $("#myPopUp").hide()

T9b
  • 3,312
  • 5
  • 31
  • 50
  • What about pop up with progress? – Joper Aug 11 '11 at 12:16
  • And one more thing i just thought, if there will be any validation errors form server i need to close this popup and display them, is it easy to do? – Joper Aug 11 '11 at 16:15
  • Yes you just put the same `.hide()` in the error method. I mentioned that already ;) – T9b Aug 12 '11 at 08:47