jquery notes: Ajax and deferred objects

Source: Internet
Author: User
Tags arrays current time numeric value

One, Ajax methods

1. Send Request

Ajax Methods Description
$. Ajax ([url],options) Send an AJAX request using the incoming options
. Load (Url,[data],[callback]) Generate an AJAX request to the incoming URL, and then place the response in the matching element
$. Get (Url,[data],[callback],[returntype]) Send a GET request to the incoming URL
$. Getjson (Url,[data],[callback]) Sends an AJAX request to the incoming URL to parse the response as a JSON data structure
$. Getscript (Url,[callback]) Sends an AJAX request to the incoming URL to parse the response as JavaScript
$. Post (Url,[data],[callback],[returntype]) Send a POST request to the incoming URL

2. Monitoring requests

Ajax Methods Description
. Ajaxcomplete (Handler) Handler that is invoked after the binding Ajax request completes
. Ajaxerror (Handler) Handler that is invoked after an error has been bound for an AJAX request
. Ajaxsend (Handler) Bind the handler that was invoked at the start of the AJAX request
. Ajaxstart (Handler) A handler to invoke when the AJAX request starts but no other AJAX request is bound
. Ajaxstop (Handler) Handler to invoke when binding Ajax request ends but no other AJAX request
. Ajaxsuccess (Handler) The handler that is invoked when the binding Ajax request successfully returns a response

3. Configure

Ajax Methods Description
$. Ajaxsetup (Options) Set options for subsequent AJAX requests
$. Ajaxprefilter ([Datatype],handler) Modify the options for each request before the $. Ajax () process the request
$. Ajaxtransport (transportfunction) Define a new transport mechanism for AJAX transactions

4. Practical Methods

Ajax Methods Description
. Serialize () Encodes the value of a set of form controls into a single query string
. Serializearray () Encodes the value of a set of form controls into a JSON data structure
$. param (obj) Encodes an object of any value into a query string
$. Globaleval (Code) The given javascipt string in the global context is evaluated
$. Parsejson (JSON) To convert a JSON object to a JavaScript object
$. Parsexml (XML) To convert an XML string to an XML document
$. parsehtml (HTML) Converting HTML elements to DOM elements

Second, delay the object

1. Creating objects

function Description
$. Deferred ([setupfunction]) To create a new deferred object
$. When (deferreds) Returns a committed object to be resolved after a given deferred object has been resolved

2. Methods of delaying objects

Method Description
. Resolve ([args]) Resolves the deferred object and completes the callback function with the given parameter call
. Resolvewith (Context,[args]) Resolves the deferred object and completes the callback function with the given parameter call, and lets the keyword this reference the context in the callback function
. reject ([args]) Reject the delay object and invoke the failed callback function with the given argument
. Rejectwith (Context,[args]) rejects the delay object and invokes the failed callback function with the given argument, while letting the keyword this reference the context in the callback function
. notify ([args]) Perform Progress callback
. Notifywith (Context,[args]) Executes the progress callback and lets the keyword this reference the context in the callback function
. Promise ([target]) Returns the committed object with the current deferred object

3. Methods of the Committed object

when the object is rejected after each time the object is notified of progress
method Ming
. Done (callback) call Callback when the object is resolved
. Fail (callback) call callback after the object is rejected
. Always (callback) is invoked after the object is rejected or resolved callback
. Then (donecallbacks,failcallbacks) calls Donecallbacks when the object is resolved, and calls Failcallbacks
. Progress (callback) calls callback
. isrejected () returns True if the object is rejected
. isresolved () returns True if the object is resolved
. State () returns the current running status, "Pending", "rejected", and "resolved"
. Pipe ([donefilter],[failfilter]) Returns the new Commitment object

Third, other methods

Properties of 1.JQuery Objects

Property Description
$. Support Returns an attribute object that indicates whether the browser supports a variety of features and standards

2. Arrays and objects

the collection of iterations, executes callback for each item, returns the result returned as a new array
function Clear
$ . each (collection,callback) Iteration Collection, execute call for each item Back
$ . Extend (target,obj1,obj2,....) Extended target object
$ . grep (Array,callback,[invert]) use callback filter array
$ .makearray (obj) converts an obj object to an array
$ . Map (array,callback)
$ . InArray (value,array) judgment Val UE is in array, not return-1
$ . Merge (array1,array2) merge Arrays array1 and Array2
$ . Unique (array) removing duplicate DOM elements from an array

3. Object Judgment

function Description
$. IsArray (obj) Determines whether object obj is an array
$. Isemptyobject (obj) To determine if object obj is empty
$. Isfunction (obj) Determine if object obj is a function
$. Isplainobject (obj) Determines whether object obj is created by literal or new object ()
$. Isnumber (obj) Determine if object obj is a numeric value
$. IsWindow (obj) Determine if object obj is a browser window
$. Isxmldoc (obj) To determine if object obj is an XML node
$. Type (obj) JavaScript class to determine object obj

Related articles: Thejudgment of variable types in JavaScript

4. Other

function Description
$. Trim (String) Remove the front and back whitespace characters of a string
$. Noconflict ([RemoveAll]) Transition to other libraries $ identifier
$. NoOp () A function that doesn't do anything
$. Now () Returns the current time in seconds
$. Holdreay (Hold) Prevent ready events from triggering or releasing the current reservation
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.