Ajax XMLHttpRequest : Creating Request Object
Previously we have learnt about different blocks in the Ajax example. This tutorial explains more about the creation of the XMLHttpRequest request object in the Ajax.
Ajax XMLHttpRequest Request :
var xmlhttp; if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
Recommanded Reading : Click here to see complete example
XMLHttpRequest Object :
- XMLHttpRequest object is supported in all modern browsers however IE5 and IE6 uses an ActiveXObject.
- Object is used to exchange data with a server without reloading the whole page.
- Updating part of web page is possible using XMLHttpRequest object
- For creating an XMLHttpRequest object in Chrome,opera,safari and Firefox, syntax is shown below -
- Old versions of Internet Explorer (IE5 and IE6) uses an ActiveX Object:
variable = new XMLHttpRequest();
variable = new ActiveXObject("Microsoft.XMLHTTP");