Sync and async commands: suggestions - Forum

Forum Navigation
You need to log in to create posts and topics.

Sync and async commands: suggestions

Hi,
in some cases in my code I use $ .ajaxSetup ({async: false}); to achieve synchronous behavior in the processing flow. I also created a small plugin with only three commands to achieve this. But I know that 'async: false' is deprecated. Is there a real and efficient alternative to get the same result that doesn't use 'async: false'?

Greetings
Rocco

@roccocogliano I think you should take a look at async/await JavaScript comands:

Making asynchronous programming easier with async and await - Learn web development | MDN (mozilla.org)
Async/await (javascript.info)

'async: false' is not only deprecated but not recommended by W3C as it blocks (hangs) the page until the response is received from the server. async/await makes asynchronous feelomg like synchronous.

I hope it helps.

roccocogliano has reacted to this post.
roccocogliano

Thank you so much @luishp.