Good Morning,
I am trying to call the same function everytime the user presses a button. Here is what happens at the moment..
User clicks button -> Calls function -> function takes 1000ms+ to finish (due to animation with jQuery and AJAX calls)
What I want to happen is every time the user presses the button it adds the function to the queue, waits for the previous call to finish, and then starts..
Is this possible?
Sorry if my explanation is a bit confusing..
Thanks Matthew
Since Functions are objects they can store properties. You can have your function increment a ‘queue’ property on itself every time its called (button pressed) and then at the end of the function execution, check if the queue property of itself is > 0, and if so, decrement the queue property by one and call itself again using
setTimeout.