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
Like
77k
AJAX Basic
AJAX HOME AJAX Intro AJAX Example
WEB HOSTING
Next Chapter
Best Web Hosting eUK Web Hosting UK Reseller Hosting Domain, Hosting & Email
AJAX XMLHttpRequest
XHR Create Object XHR Request XHR Response XHR readyState
AJAX Advanced
AJAX ASP/PHP AJAX Database AJAX XML File
STATISTICS
Browser Statistics OS Statistics Display Statistics
AJAX Examples
AJAX Examples
v a r i a b l e = n e wX M L H t t p R e q u e s t ( ) ;
Old versions of Internet Explorer (IE5 and IE6) uses an ActiveX Object:
v a r i a b l e = n e wA c t i v e X O b j e c t ( " M i c r o s o f t . X M L H T T P " ) ;
To handle all modern browsers, including IE5 and IE6, check if the browser supports the XMLHttpRequest object. If it does, create an XMLHttpRequest object, if not, create an ActiveXObject:
Example
v a rx m l h t t p ; i f( w i n d o w . X M L H t t p R e q u e s t ) { / /c o d ef o rI E 7 + ,F i r e f o x ,C h r o m e ,O p e r a ,S a f a r i x m l h t t p = n e wX M L H t t p R e q u e s t ( ) ; } e l s e { / /c o d ef o rI E 6 ,I E 5 x m l h t t p = n e wA c t i v e X O b j e c t ( " M i c r o s o f t . X M L H T T P " ) ; }
Try it yourself In the next chapter you will learn about sending server requests.
Previous
Next Chapter
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 SVG 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 Browser Display
w3schools.com/ajax/ajax_xmlhttprequest_create.asp
1/2
8/8/13
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_create.asp
2/2