Skip to content
Advertisement

JQuery Ajax loop delay

i am trying to make a delay in my ajax data so the loop become a little bit slower ! and here is my code

JavaScript

here is the loop

JavaScript

Advertisement

Answer

Using recursion, you could put in a function sendToServer and pass through the array lines, starting index 0. The function will run from 0 to lines.length. This way you won’t DDOS your server 🙂

If you really need some kind of arbitrary delay, you can include a timeout on the sendToServer function call – in the example it is set to 5 seconds.

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement