0

Disclaimer: I am still learning and don't have a lot of experience.

At the moment for ALL of my XMLHttpRequests I am using async = true.

The problem is, when one requests takes longer and the user does not want to wait for the request and he clicks somewhere else and this XMLHttpRequests loads faster, we see the content of the second request and when the first XMLHttpRequests finishes it overwrites the second content.

I know that I could still use async = true, when the rest of the code would be better, but it is way easier to change to false, instead of changing hundreds of files.

I changed it to false, but I am afraid that this will cause other problems.

Can anyone tell me when to use async = true and when async = false. And if there might be any problems using async = false?

Thank you in advance! :-)

DDJS
  • 1
  • https://stackoverflow.com/questions/33053955/why-is-synchronous-xmlhttprequest-considered-as-deprecated – Bergi Jun 07 '19 at 13:21
  • If you'r using one call dependent on other then async=false will work. If both calls are independent then asyn=true is the best practice and if you want to use concurrent behavior then also asyn= true will be best choice. Asyn dosen't impact on the speed of the call. – Mudit Jun 07 '19 at 13:51
  • Thanks Bergi and Mudit - I don't need any impact on the speed of the call, so that is not an issue. I want to use it only on calls not related to other tasks like "load customer1" and "load customer2", want to avoid that if user clicks on "load customer2" while waiting for "load customer1" that customer2 is loaded and not waiting getting overwritten with customer1 data, when the first click took to long – DDJS Jun 07 '19 at 14:16

0 Answers0