Jump to content

disabling user actions


lsgen

Recommended Posts

Hello ,I have a web page with several buttons that (using ajax) allows me to perform some actions (remotly); the actions are performed by the http server; the answers from the server take about 2 seconds to be available on the web page; during this time I want to prevent the user to start a new action (showing something like a gray screen or something like this). I´ll appreciate any help.Thanks

Link to comment
Share on other sites

Hopefully, you are using jQuery :) You can place the buttons in a div and then do something like

<form action="#" method="post"><div id="someId"><input type="button" onClick="sendRequest();return false;" value="Submit" name="someButton"/></div></form><script>function sendRequest() {  $('#someId').html('Loading...');  setInterval('showButton()',2000); // too lazy to make an ajax request }function showButton() {  $('#someId').html('<input type="button" onClick="sendRequest();return false;" value="Submit" name="someButton"/>');}</script>

So on the success of your ajax request, you can call the function showButton() to remove the 'loading...' message. Of course, you could also set the HTML to a loading .gif image instead.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...