Sort out common Ajax APIs

Source: Internet
Author: User

Standard XMLHttpRequest methods include:

Abort stops the current request

GetAllResponseHeaders returns all HTTP Request Response Headers as healthy values.

GetResponseHeader ("Header") returns the string value of the specified header.

Open ("method", "url") creates a call to the server. The method parameter can be get, post, or put, and the URL parameter can be relative URL or absolute URL, this method also includes three optional parameters.

Send (content) sends a request to the server

SetRequestHeader ("Header", "value") sets the specified header to the provided value. You must call open

 

Standard XMLHttpRequest attributes

Onreadystatechange: This event processor is triggered when every state change. Generally, the status of a JavaScript function request is called. Five values are available, 0 = not initialized, and 1 = loading, 2 = loaded, 3 = interaction in progress, 4 = completed

Responsetext server response, indicating the server response, expressed as XML, which can be parsed as a DOM object

Status Server HTTP status code (200 corresponds to OK, 404 corresponds to not found (not found), and so on

Corresponding text of statustext HTTP status code (OK or notfound (not found)

W3C Dom attributes and methods used for dynamic content creation

Document. createelement (tagname) The createelement method on the document object can create elements specified by tagname. If the string div is used as the method parameter, a div element is generated.

Document. createtextnode (text) The createtextnode method of the Document Object creates a node that contains static text.

<Element>. appendchild (childnode) appendchild method adds the specified node to the list of child nodes of the current element (as a new child node ). for example, you can add an option element as a subnode of the select element.

<Element>. getattribute (name) methods are used to obtain the value of the name attribute in the element.

<Element>. setattribute (name, value): set the value of the element name attribute.

<Element>. insertbefore (newnode, targetnode) This method inserts the node newnode as the child node of the current element in front of the targetnode element.

<Element>. removeattribute (name): This method deletes the attribute name from the element.
<Element>. removechild (childnode): This method deletes the child element childnode from the element.
<Element>. replaceChild (newnode, oldnode) replaces the oldnode with the newnode.
<Element>. haschildnodes returns a Boolean value indicating whether the element has child elements.

 

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.