Jquery Study Notes (5) ajax

Source: Internet
Author: User

$ (Selector). load (Url [, date] [, callback])

Url: the url of the Request page.

Date: key: value data sent to the server

Callback: the callback function when the request is complete. no matter whether the request is successful or fails, it is called when the XMLHttpRequest object is in the status of 4 or complete.

 

This function inserts the content returned by ajax into the selector as innerHTML. If necessary, you can add parameters after the url to filter the content to be inserted.

If the date parameter exists, it is sent in POST mode; otherwise, it is sent in GET mode. The format of date data is {key1: value1, key2: value2 ...}

The callback function automatically passes in three parameters: returned content, Request status, and XMLHttpRequest object. The Request status refers to the status returned by the server, rather than the XMLHttpRequest object. The Request status is divided into four states: success, error, notmodified, and timeout.

 

$. Get (Url [, date] [, callback] [, type])

Url: the url of the Request page.

Date: key: value data sent to the server. Format: {key1: value1, key2: value2 ...}

Callback: the callback function when the load is successful, that is, when the server returns status 200. Two parameters are automatically input. The first parameter is the returned content, and the second parameter is the Request status.

Type: it does not seem to work much.

This function will send data in GET Mode

$. Post (Url [, date] [, callback] [, type])

The usage is the same as the $. get method, except that the method for sending data is POST.

 

$. GetScript (Url [, callback])

Functions used to dynamically load js scripts

Url: url of the script to be loaded

Callback: the callback function after the script is loaded successfully.

$. GetJSON (Url [, callback])

Functions used to load json files

Url: url of the json file to be loaded

Callback: the callback function after the json file is successfully loaded. A parameter, namely, a json object, is automatically input.

 

$. Ajax (Opitions)

Opitions is a key: value object, which specifies various parameters. Common parameters include:

Url:

Type:

Timeout:

Date:

Datetype:

BeforeSend:

Complete:

Success:

Error:

For more information about jquery, see the reference manual. This function is unlikely to be used.

 

$. Each (Objecy/array, callback)

A function used to traverse arrays or objects. This function can only traverse one layer. to traverse multiple layers, you must use it again.

Object/array: array or object to be traversed

Callback: The operation function will automatically pass in two parameters. The first is the object's member or array index, and the second is the specific content.

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.