jquery - ajax calls being called too fast -


I have a page with a link, so that the user clicks Facebook to log our API. When you click on it, it calls an Ajax function which calls a php method to remove the user's key from our database, then calls the Facebook API logout function with a JS command. This calls Facebook and the user ends the session. Once logged out, it refreshes the page.

My problem is that it seems that the database update is not going to end and the logout of Facebook is not being waited and the page has been refreshed. Since it does not meet it, the information is never removed and my site never gets logged out. Every once in a while, this is a delay, but probably clicks 10 times every time.

I put a set time for 2 seconds, but it still does not work.

Any thoughts?

Do not use setTimeout to try a follow-up time Action to call Ajax instead use a callback function; This way it is guaranteed to execute only after the Ajax call is over.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -