From Ajax to JQuery Ajax

Source: Internet
Author: User

AjaxArticle

XMLDocumentAnd XMLHttpRequestObject
1. Create an XMLHttpRequest request objectCopy to Clipboard reference content: [www.bkjia.com] function getXMLHttpRequest (){
Var xRequest = null;
If (window. XMLHttpRequest ){
XRequest = new XMLHttpRequest ();
} Else if (typeof ActiveXObject! = "Undefined "){
XRequest = new ActiveXObject ("Microsoft. XMLHTTP ");
}
Return xRequest;
}

Or:

Copy to ClipboardReference: [www.bkjia.com] var request = null;

Function createRequest (){

Try {

Request = new XMLHttpRequest (); // non-Microsoft IE browser

} Catch (trymicrosoft) {// Microsoft IE

Try {

Request = new ActiveXObject ("Msxml2.XMLHTTP ");

} Catch (othermicrosoft ){

Try {

Request = new ActiveXObject ("Microsoft. XMLHTTP ");

} Catch (failed ){

Request = null;

}

}

}

If (request = null)

Alert ("Error creating request object !");

}

This independent function for creating the XMLHttpRequest request object can be called.

Note:: XMlHTTP objects are not W3C standards. Therefore, you must consider the support of different browser environments when creating them.

The XMLHTTP object has 6 methods and 8 attributes. It supports two execution modes: synchronous and asynchronous.

XMLHTTP objectAttributeAndMethodList (from IXMLHTTPRequest Interface ):

Attribute name

Type

Description

Onreadystatechange

N/

Specifies the event processing function called when the ready status changes. It is only used for asynchronous operations.

ReadyState

Long

Asynchronous Operation Status: Not initialized (0), loading (1), loaded (2), InterAction (3), completed (4)

ResponseBody

Variant

Returns the response body as an unsigned byte array.

ResponseStream

Variant

Returns the response body as an ADO Stream object.

ResponseText

String

Returns the response body as a text string.

ResponseXML

Object

Resolve the response body to an XMLDocument object through XMLDom

Status

Long

HTTP status code returned by the server

StatusText

String

Server HTTP Response line status

Method Name

Description

Abort

Cancel current HTTP Request

GetAllResponseHeaders

Retrieve all header fields from the response information

GetResponseHeader

Obtain an HTTP header field value from the response body.

Open (method, url, boolAsync, bstrUser, bstrPassword)

Open a connection to the HTTP server

Send (varBody)

Send a request to the HTTP server. Body.

SetRequestHeader (bstrHeader, bstrValue)

Set the header field of a request

  • Four pages in total:
  • Previous Page
  • 1
  • 2
  • 3
  • 4
  • Next Page

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.