Examples of ajax load () and post () methods in jQuery _ jquery

Source: Internet
Author: User
This article mainly introduces the load () and post () Methods of ajax in jQuery, and analyzes the load () and post () methods in jQuery in detail using examples () methods To achieve ajax interaction related skills and precautions, you can refer to the example of this article describes the ajax load () and post () methods in jQuery. We will share this with you for your reference. The details are as follows:

I. load () method

The load () method of jQuery ajax can load remote HTML file code and insert it into the DOM. This is a little different from post and get, however, you can quickly load the html of a page during page loading and save it to the dom for execution.

The load () method uses the GET method by default. If the data parameter is passed, the Post method is used.

The POST method is automatically converted when additional parameters are passed. In jQuery 1.2, you can specify a selector to filter loaded HTML documents. In DOM, only filtered HTML code is inserted. The syntax is like "url # some> selector". The default selector is "body> *".

Explanation:

Load is the simplest Ajax function, but its usage has limitations:

1. It is mainly used to directly return HTML Ajax interfaces.
2. load is a jQuery packaging set method. It needs to be called on the jQuery packaging set and will load the returned HTML to the object, even if the callback function is set, it is undeniable that the load interface is cleverly designed and easy to use. the following example shows how to use the Load interface:

Load () function:

Function Introduction: load (url, [data], [callback]) Return Value: jQuery

Parameter description:

Url: the url of the HTML webpage to be loaded.
Data: (optional) key/value data sent to the server.
Callback: (optional) callback function when loading is successful.

The following is an example:

First, create the following test.html file:

 Ajax demoScript home (www.jb51.net) provides a large number of scripts and materials for you to download!

After creating the ajax.html file, remember to introduce jquery.

 
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.