Example of ajax in jquery ($. ajax ())

Source: Internet
Author: User
Examples of ajax in jquery. There are many common examples about the meaning of ajax parameters in jquery. I mainly introduce two common examples to get the returned result through responseText; 20540; Use responseText to obtain the returned value function ajax examples in jquery. There are many common examples about the meaning of parameters in ajax in jquery.

// Obtain the returned value using responseText.

// Obtain the returned value function check () {var data = $. ajax ({type: "post", url: "smsrecharge! Check. action? V = "+ $ (" # I _smsaccount_id "). val () + "& v1 =" + $ ("# id "). val () + "& p =" + new Date (), async: false }). responseText; if (data = "true") {return "the company already has a recharge account. Please reselect" ;}else {return true ;}} // use success in ajax to obtain the returned value. data is the returned value function queryRemain () {$. ajax ({type: "post", // defines the submitted type url: "smsrecharge! QueryRemainMoney. action? V = "+ $ (" # I _smsaccount_id "). val () + "& v1 =" + $ ("# id "). val () + "& p =" + new Date (), // The requested address dataType: "json", // set the returned value type async: false, // asynchronous request or not. false indicates synchronous success: function (data) {// successful return value execution function if (data. c <0) {$ ("# remain_moneyTip" 2.16.html ("the balance query is loading... ") ;}$ (" # remain_money "). val (data. r );}});}

Note:
The default value of async is true, which is asynchronous, that is, when ajax sends a request,
In the process of waiting for the server to return, the foreground will continue to execute the script after the ajax block until the server returns the correct result to execute success,
That is to say, two threads are executed at this time. After the ajax block sends a request, one thread and the script after the ajax block (another thread)




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.