lsgen Posted December 26, 2012 Share Posted December 26, 2012 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 More sharing options...
jardrake Posted December 28, 2012 Share Posted December 28, 2012 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now