Reputation: 93
There might be some cases that your request takes long time because of some problems with your client internet connection or your server connection. So since the client doesn't want to wait he clicks on the Ajax link again which sends the request to the server again which messes up the following:
I want to stop the 1st Ajax response if the Ajax function is called twice. How do I do this?
Upvotes: 1
Views: 391
Reputation: 18344
so i want to stop the 1st Ajax response if the Ajax function is called twice
What you actually want is to prevent a second request when a first request is in progress.
For example, You may have to change the Save
button to Saving...
, disable it (and add a little progress wheel) to give live feedback to the user. (Facebook does this)
The key is love feedback to the user. If the user is clueless on what is going on, they are going to think nothing is happening.
You might want to check why the operation is taking long
Upvotes: 4
Reputation: 36937
How bout seeing as your using some form of JavaScript to begin with you have that link either hidden or disabled in a manor of speaking til the pages request has been followed through with. You could for example have the requested ajax wait for a second variable that would enable that link so a user could click it. But until that variable is received from the original AJAX request its disabled to the click, then if it is clicked it disables again and waits for the same variable to come back again.
Think of how some developers disable a submit button on a form so a user can't double submit there form.. same concept of notion here.
Upvotes: 0