Ajax asynchronous Processing

Source: Internet
Author: User

Ajax is usually used for asynchronous processing, but in some cases, Ajax synchronization is used to process data. For example, when detecting data with JS, Ajax is required to submit a request to obtain whether the user exists in the database, this requires synchronous processing to wait for the data returned by the server to perform the next operation. If asynchronous processing is used, the program will not wait for the data returned by the server, so an error will occur, no problem with Ajax synchronization. The following is a very simple Ajax synchronous data submission function in jquery:
 

JS Code
Http://www.xueit.com
Function extaajax (pmts) {var ajaxval = NULL; var Params = "ajax = true &" pmts; // URL parameter $. ajax ({URL: 'xueit-test. aspx ', // receiving page type: 'post', // send data async: false in post mode, // Ajax synchronize data: Params, success: function (MSG) {ajaxval = MSG ;}}); Return ajaxval ;}

 

Usage:
VaR url = "username = IT & mail = it@qq.com ";
VaR result = NULL;
Result = extajax (URL );
Alert (result); // The alert result is displayed.

Finally, you can click "add jquery document to favorites jquery. Ajax parameter introduction list" to read the Ajax parameters in jquery.

From: http://www.xueit.com/html/2009-10-21/33-1622523252812.html

Related Article

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.