2

I know that in general the goal should be to avoid async: false. However, in this situation, I want to understand whether it's worth tying things together to make it work, or if it is okay:

On my site's registration page, I have a JS/jQuery validation function on submission. It has two AJAX queries, one for the username (to make sure it hasn't already been taken), and one for the email (to make sure they didn't submit an email already claimed by another user). In the validation function, I check each of these, along with lots of other things (passwords matching, check not blank, etc.), and when either of these pop up, a warning message states the issue.

Both of these ajax queries use async: false in order to ensure that the form doesn't submit before they are checked.

My question is,
how bad is this? And if it's bad bad, then why? I could put the work in to make a single function that checks both and has 4 return values for each of the different options, but that seems like a lot... I know this may not be a solid coding question, but I'm new to coding and want to make sure I understand what the difference here means.

Thanks so much in advance.

1 Answer 1

1

Synchronous HTTP requests halt execution of subsequent code while they are en route. While browsers may no longer block the UI during this time, we're relying on the user's available bandwidth, network reliability, and the server's current load for the performance of our code. This is generally not good practice.

as i have found from this link may this will help you please look at this https://softwareengineering.stackexchange.com/questions/112551/should-we-still-consider-a-synced-xmlhttprequest-bad-practice

you should also reffer to https://webtide.com/xmlhttprequest-bad-messaging-good/

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.