Jump to content
Sign in to follow this  
lsgen

disabling user actions

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...