Using AJAX synchronous request to solve the problem that login registration needs to be judged by the server return data

Source: Internet
Author: User

Recently registered in writing Www.doubilaile.com's login. Need to use AJAX to request the server to determine whether the user name exists, the user name and password match, and then submit the data. The problem is that an asynchronous request can successfully return data, but that data cannot be relied upon for immediate judgment. My understanding now is that the asynchronous request goes to the server side, and the local code is still executing down. The server data does eventually come back, but the local judgment is done. So the password box will appear after the individual blur can be submitted, and the direct submit button to press two times to submit the problem. Resolves the synchronization to an asynchronous problem. The understanding is that the synchronization will wait for the server data to return before continuing to execute, so the returned data can be used as a basis for judging, as long as the conditions are met, the form is naturally successfully submitted.

Using AJAX synchronous request to solve the problem that login registration needs to be judged by the server return data

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.