DOM and XMLHttpRequest object attributes and methods, domxmlhttprequest_PHP tutorial

Source: Internet
Author: User
The attributes and methods of DOM and XMLHttpRequest objects, domxmlhttprequest. DOM and XMLHttpRequest object attributes and methods, domxmlhttprequest standard XMLHttpRequest operation method description abort () stop the current request getAllResponseHeaders () put all the attributes and methods of the HTTP request DOM and XMLHttpRequest object, domxmlhttprequest
Standard XMLHttpRequest operations

Method

Description

Abort ()

Stop current request

GetAllResponseHeaders ()

Returns the header of all HTTP requests as the creation/value.

GetResponseHeader ("header ")

Returns the string value of the specified header.

Open (String "method", String "url,

Bollean [asynch],

String [username],

String [password])

Call the created Server. the method parameter can be post, get, or put. Url parameters can be relative URLs or absolute URLs. This method also includes three optional parameters.

Send (content)

Requests sent by servers

SetRequestHeader ("header", "value ")

Set the specified header to the provided value. You must call open () before setting any header ().

Standard XMLHttpRequest attributes

Method

Description

Onreadystatechange

This event processor is triggered when the status changes. generally, a javascript function is called.

Readystate

Request status. Five values are available:

1 = not initialized,

2 = loading,

3 = loaded,

4 = interaction,

5 = complete.

ResponseText

Server response, which is a string.

ResponseXML

The response of the server, expressed as XML. this object is generally parsed as DOM..

Status

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

StatusText

The corresponding text of the HTTP status code (OK or not found (not found) and so on)

Used to process DOM element attributes of XML

Attribute name

Description

ChildNodes

Returns an array of all child elements of the current element.

FirstChild

Returns the first subelement of the current element.

LastChild

Returns the last child element of the current element.

NextSibling

Returns the elements that follow the current element.

Nodevalue

Indicates the read/write attribute of the element value.

ParentNode

Returns the parent node of an element.

Previussibling

Returns the element adjacent to the current element.

DOM element method used to traverse XML

Method name

Description

GetElementById (id) (document)

Obtain the elements in the document with the specified unique ID property value

GetElementsByTagName (name)

Returns an array of child elements with specified names in the current element.

HasChildNodes ()

Returns a boolean value indicating whether the element has a child element.

GetAttribute (name)

The attribute of the returned element. the attribute is specified by name.

W3C DOM attributes and methods used for dynamic content creation

Attribute/Method

Description

Docment.CreateElement (tagName)

The createElement method on the document object can create elements with the tagname specified. If the DIV string is used as the parameter, a DIV element is generated.

Docment.CreateTextNode (text)

The createTextNode method on the document object creates a node that contains static text.

.AppendChild (childNode)

AppendChild adds the specified node to the subnode list of the current node (as a new subnode ). For example, you can add an option element as a subnode of the select element.

.GetAttribute (name)

These methods respectively set the value of the name attribute in the element.

.GetAttribute (name, value)

.InsertBefore (newNode, targetNode)

This method inserts the node newNode as the child node of the current element before the targetNode element.

.RemoveAttribute (name)

This method deletes the attribute name from the element.

.RemoveChild (childNode)

This method deletes the child element childNode from the element.

.ReplaceChild (newNode, oldNode)

This method replaces newNode with oldNode.

.HasChildnodes ()

This method returns a boolean value indicating whether the element has child elements.

Usage standard XMLHttpRequest operation method description abort () stop the current request getAllResponseHeaders () to send all HTTP requests...

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.