Ajax-jquery method-Getting Started 01 (finishing), ajax-jquery01

Source: Internet
Author: User

Ajax-jquery method-Getting Started 01 (finishing), ajax-jquery01

----------------------------------- 7.07.21 write -----------------------------------------

Compared with native javascript, jquery's ajax is easy to understand. One is 100x100, and the other is 1 + 1. Thanks to John Resig.

1 <script type = "text/javascript"> 2 $ (function () {3 $ (". btn "). click (function () {4 var obj = {5 url: "http: // localhost/test.txt", // required. The address 6 type: "GET", // required. Sending Method 7 data: "", // optional. Data sent to the server, which is generally of the Object Type 8 dataType: "text", // optional. Specifies the expected server response data type. Intelligent judgment (xml, json, script, or html) is performed by default ). For jsonp, specify 9 success: function (msg) {// optional. Callback function 10 console. log (msg); 11}, 12 error: function (err) {// optional. Callback Function 13 console. log (err); 14} 15}; 16 $. ajax (obj); 17}); 18}); 19 </script>

Generally, it can be directly copied and used.

Modify the callback function of url, type, data, dataType, and success according to the actual situation.

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.