How do I do a jQuery blocking AJAX call without async false?
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
In browser JavaScript, there is no good modern way to do a truly blocking AJAX request on the main UI thread without using async: false, and that option is deprecated for good reason. It freezes the page, prevents user interaction, and creates a bad user experience. The real fix is usually to stop thinking in terms of "block until it finishes" and instead structure the code so later steps run after the request resolves.
Why async: false Is the Wrong Goal
This older pattern blocks the browser until the response arrives:
That means:
- the page cannot repaint
- clicks and keyboard input are stalled
- slow networks make the app feel broken
So the right question is usually not "How do I block without async: false?" but "How do I sequence my logic without blocking the browser?"
Return a Promise and Chain the Next Step
$.ajax() already returns a jQuery promise-like object, so you can return it and run dependent code in then().
This does not block the browser, but it does preserve the order of operations. The second request only runs after the first one succeeds.
Use async and await for Clearer Flow
If your environment supports modern JavaScript, you can wrap the jQuery request and write code that looks more linear.
This is still asynchronous, but it solves the original control-flow problem in a much cleaner way than nested callbacks or a synchronous request.
If You Need to Stop Submission or Navigation
Sometimes developers say "blocking AJAX" when they really mean "do not continue this action until the server responds." For example, when submitting a form, prevent the default action first, then continue in the success handler.
The user action is gated by the server response, but the browser is not frozen.
If You Need a Temporary UI Lock
Sometimes the real requirement is not a synchronous request but preventing duplicate clicks. In that case, disable the relevant UI and re-enable it when the request finishes.
That gives you the practical effect many people wanted from "blocking" without harming the entire page.
Common Pitfalls
The most common mistake is trying to return the AJAX result from the outer function immediately:
This returns too early because the request has not finished yet. Return the promise instead.
Another mistake is mixing callbacks, jQuery Deferred methods, and async/await without a clear pattern. Pick one style and use it consistently.
Some developers also freeze the UI unnecessarily when a local loading indicator or disabled button would solve the real problem. Blocking the whole page is usually a sign that the interaction model needs to be rethought.
Summary
- There is no good modern way to do a truly blocking browser AJAX call without
async: false. - The correct replacement is usually promise chaining or
asyncandawait. - If an action must wait for the server, continue it in the success path instead of freezing the UI.
- If you only need to prevent duplicate input, disable the relevant controls temporarily.
- Returning a promise is the key pattern for sequencing AJAX-dependent code cleanly.
Related reading
- How do I do async RPC calls with RabbitMq
- How do I ensure all calls are returned and pushed into the array before passing the action to the reducers?
- How do I execute Node JS function in order
- How do I get a return value from Task.WaitAll in a console app?
- How do I dynamically assign properties to an object in TypeScript?
- How do I find out which DOM element has the focus?
- How do I get the backtrace for all the threads in GDB?
- How do I get Visual Studio to stay on one thread when debugging?
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.