0

In my project, you can activate several created task by toggling an activation switch.

enter image description here

problem is, if I toggle two switches say ON in quick succession, only the last one get successfully completed.

How do I implement some waiting mechanism such that the ajax request for subsequent activation is pending until the previous ones are completed before they are fired?

W3Guy
  • 657
  • 1
  • 7
  • 16
  • What is your current code? What have you tried? – Samyok Nepal Nov 27 '17 at 21:23
  • This is simliar to what your looking for - https://stackoverflow.com/questions/3709597/wait-until-all-jquery-ajax-requests-are-done?rq=1 – Ryan Holmes Nov 27 '17 at 21:29
  • It's not similar because there is only one function that listen to the change event on the toggle/switch and the fire the ajax request. – W3Guy Nov 27 '17 at 21:31
  • @Collizo4sky does your console show all those requests? i mean are you sure triggering all those request at once are not aborting all the requests but the last? – Muhammad Omer Aslam Nov 27 '17 at 21:32
  • Console show all request are being sent and none is aborting. I just want a delay mechanism that put subsequent requests on hold until current one is completed. – W3Guy Nov 27 '17 at 21:34
  • You could send the values of all the switches with every ajax request, then it doesn't matter if only the last request gets processed by the server – miknik Nov 27 '17 at 23:09
  • @miknik Exactly what I thought of doing last night. Great suggestion. – W3Guy Nov 28 '17 at 10:12

0 Answers0