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