Blocking jQuery.ajax requests and jQuery.ajaxQueue
by Kristian Kraljic, April 17, 2016
Working with jQuery became a de facto web standard. Besides HTML document traversal and manipulation, it is mainly used to make Asynchronous JavaScript and XML (AJAX) easy to use and browser independent.
With AJAX, web applications can send data to and retrieve from a server (as the name suggests) asynchronously. Well, that’s not entirely true. Most AJAX libraries and APIs do indeed provide functions to retrieve data synchronously… even if it sounds like a contradiction. In jQuery for example, you may set the async
parameter to false
, in order to do a synchronous request. Doing synchronous requests from time to time makes a lot of sense, even in modern web applications given the right use case. Now you might ask yourself, "well if I don’t do it often and process the data asynchronously otherwise, what could possibly go wrong?". In this article I would like show you one case, in which mixing synchronous and asynchronous AJAX had completely messed up the web experience of one of my applications.