Tutorial on XMLHttpRequest objects and Dom objects

Source: Internet
Author: User
Tags object model tag name tagname
Property
Description

onreadystatechange

event triggers for state changes

readyState

Object State (integer):
0 = not initialized
1 = in Read
2 = has been read
3 = in Interaction
4 = Complete

ResponseText

The server process returns a text version of the data

Responsexml

compatibility of server process return data DOM of the XML Document Objects

Status

status code returned by the server , such as: 404 = " File not found " , = " Success "

StatusText

status text information returned by the server


ways to XMLHttpRequest objects:


Method

Description

abort ()

Stop Current request

getallresponseheaders ()

returned as a string to the complete Headers

getResponseHeader ("Headerlabel")

returns a single string of Header label

Open ("Method", "URL" [, asyncflag[, "UserName" [, "Password"]])

set the target of a pending request URL , methods, and other parameters

Send (content)

Send Request

setRequestHeader ("label", "value")

Set up Header and send it along with the request

Second, DOM objects
The Document Object model is a platform-and language-independent interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document. The document can be processed further, and the resulting processing can be put back in the provided page. If the server returns XML, use responsexml to create the DOM directly to manipulate the file.

DOM properties of the object:


Property

Description

childnodes

returns the collection of all child elements of the current element

FirstChild

returns the first child element of the current element

LastChild

returns the last child element of the current element

nextSibling

returns the element immediately following the current element (peer)

previoussibling

returns the element immediately preceding the current element (peer)

nodevalue

Specify a read / Write Property that represents the value of an element

parentnode

Returns the parent node of an element

DOM method of the object:


Method

Description

getElementById (ID) (document)

gets a specified unique ID elements in a property value document

getElementsByTagName (name)

returns a collection of child elements in the current element that have the specified tag name

HasChildNodes ()

returns a Boolean value indicating whether the element has child elements

getattribute (name)

returns the attribute value of an element, which is attributed to the name Specify

used to dynamically create content W 3C DOM Properties and Methods


Property / Method

Description

document.createelement (tagName)

on the Document object createelement method can be created by the TagName the specified element. If the string div is used as a method parameter, a div element is generated

document.createTextNode (text)

of the Document object createTextNode method creates a node that contains static text

element. appendchild (Childnode)

appendchild method to specify the node Childnode add to the list of child nodes of the current element

element. Getattribut (name)
element. Setattribut (name, value)

gets and sets the element in the name the value of the property

element. InsertBefore (NewNode, TargetNode)

This method adds the node NewNode inserted as a child node of the current element into the TargetNode element Front

element. RemoveAttribute (name)

This method removes the attribute from the element name

element. RemoveChild (Childnode)

To remove a child element from an element Childnode

element. replacechild (NewNode , OldNode)

the node OldNode Replace with a node NewNode

element. HasChildNodes ()

returns a Boolean value , indicates whether an element has child elements

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.