Вы находитесь на странице: 1из 2

8/8/13

AJAX XMLHttpRequest Server Response


Search w3schools.com: Select Language

HOME

HTML

C SS

JAVASC RIPT

JQUERY

XML

ASP.NET

PHP

SQL

MORE...

R EFER ENC ES

EXAMPLES

FO R UM

ABO UT

Get Certified
Study Web Technologies and get a diploma at w3schools.com

SHARE THIS PAGE

Like

77k

AJAX Basic
AJAX HOME AJAX Intro AJAX Example

AJAX - Server Response


Previous Next Chapter

WEB HOSTING
Best Web Hosting eUK Web Hosting UK Reseller Hosting Domain, Hosting & Email

AJAX XMLHttpRequest
XHR Create Object XHR Request XHR Response XHR readyState

Server Response
To get the response from a server, use the responseText or responseXML property of the XMLHttpRequest object. Property responseText responseXML Description get the response data as a string get the response data as XML data

WEB BUILDING
Download XML Editor FREE Website BUILDER FREE Website C reator

AJAX Advanced
AJAX ASP/PHP AJAX Database AJAX XML File

The responseText Property


If the response from the server is not XML, use the responseText property. The responseText property returns the response as a string, and you can use it accordingly:

Best Website Templates

STATISTICS
Browser Statistics OS Statistics

AJAX Examples
AJAX Examples

Example
d o c u m e n t . g e t E l e m e n t B y I d ( " m y D i v " ) . i n n e r H T M L = x m l h t t p . r e s p o n s e T e x t ;
Try it yourself

Display Statistics

The responseXML Property


If the response from the server is XML, and you want to parse it as an XML object, use the responseXML property:

Example
Request the file cd_catalog.xml and parse the response:

x m l D o c = x m l h t t p . r e s p o n s e X M L ; t x t = " " ; x = x m l D o c . g e t E l e m e n t s B y T a g N a m e ( " A R T I S T " ) ; f o r( i = 0 ; i < x . l e n g t h ; i + + ) { t x t = t x t+x [ i ] . c h i l d N o d e s [ 0 ] . n o d e V a l u e+" < b r > " ; } d o c u m e n t . g e t E l e m e n t B y I d ( " m y D i v " ) . i n n e r H T M L = t x t ;
Try it yourself

Previous

Next Chapter

Cancer Center Services


rsa-inc.com/service Reliable, on time solutions for your Linear Accelerators

Top 10 Tutorials
HTML Tutorial HTML5 Tutorial C SS Tutorial C SS3 Tutorial JavaScript Tutorial jQuery Tutorial SQL Tutorial PHP Tutorial ASP.NET Tutorial XML Tutorial

Top 10 References
HTML/HTML5 Reference C SS 1,2,3 Reference C SS 3 Browser Support JavaScript HTML DOM XML DOM PHP Reference jQuery Reference ASP.NET Reference HTML C olors

Examples
HTML Examples C SS Examples XML Examples JavaScript Examples HTML DOM Examples XML DOM Examples AJAX Examples ASP.NET Examples Razor Examples ASP Examples

Quizzes
HTML Quiz HTML5 Quiz XHTML Quiz C SS Quiz JavaScript Quiz jQuery Quiz XML Quiz ASP Quiz PHP Quiz SQL Quiz

Color Picker

Statistics
Browser Statistics Browser OS

w3schools.com/ajax/ajax_xmlhttprequest_response.asp

1/2

8/8/13

AJAX XMLHttpRequest Server Response


SVG Examples Browser Display

RE P O RT E RRO R

HO ME

TO P

P RI N T

FO RU M

A BO U T

A D V E RT I SE WI T H U S

W3Schools is optimized for learning, testing, and training. Examples might be simplified to improve reading and basic understanding. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using this site, you agree to have read and accepted our terms of use and privacy policy. C opyright 1999-2013 by Refsnes Data. All Rights Reserved.

w3schools.com/ajax/ajax_xmlhttprequest_response.asp

2/2

Вам также может понравиться