Deep Analysis ajax--Series (i)

Source: Internet
Author: User

People who often write scripts sometimes use $ajax and sometimes use $post and $get, which are used to get static data files from a Web server.

jquery encapsulates Ajax operations, in jquery the $.ajax () method is the lowest-level method, the 2nd layer is the load (), $.get (), and $.post () methods, and the 3rd layer is the $.getscript () and $.getjson () methods.

1)$.ajax () This method believes that everyone will not be unfamiliar, at the lowest level, the most abundant function.

2) The load () method is the simplest and most commonly used AJAXFANGFA in jquery, which can be loaded into the remote HTML code and inserted into the DOM.

A) examples are as follows:

$ (function () {$ ("#send"). Click (function () {$ ("#resText"). Load ("test.html");});

b) You can also filter the contents of the load, for example, to load only the content of class para in the test.html page:

$ ("#resText"). Load ("test.html  . para");


c) In addition, the way of transmission is particularly noteworthy, if there is no parameter when passed, then is the Get method is passed, if there is a parameter for the Post method passed


D) The three callback parameters of its callback function should also be paid more attention to, for example;

$ ("#resText"). Load ("test.html", function (responsetext,textstatus,xmlhttprequest) {//responsetext   : Request returned content// Textstatus:       Request Status: Success, error, notmodified, timeout 4 kinds of//xmlhttprequest:xmlhttprequest objects});

Deep Analysis ajax--Series (i)

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.