jquery Ajax's use of load, post, get, put, delete

Source: Internet
Author: User

1. Load ()

The load () method is typically used to obtain a static data file from the server.

If you need to pass some parameters to the server in your project, you can use the $.get () or $.post () method or the $.ajax () method

2, $.get ()

  $.get () uses the Get method to make an asynchronous request with a structure of $.get (Url,[data],[callback]);

Description: URL is the request address,

Data is requested, can be in the object ({key:value}) format, or can be stitched to the back of the URL,

Callback is the callback function after the request succeeds, the server returns a string

function(data) {
The returned data is a string type
});

3. Post ()

$.post (Url,[data],[callback],[type])

Description: This function is similar to the $.get () parameter, has a type parameter, type is the requested data type, can be a type of Html,xml,json, if we set this parameter to: JSON, then the returned format is in JSON format, if not set, and $. Get () returns the same format as the string.

$.post ("data.php", data, function(data) {     $ ("#postResponse"). HTML (data.name);},"JSON");   Sets the type of data obtained, so the resulting data format is a JSON-type

jquery Ajax's use of load, post, get, put, delete

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.