Friday, April 20, 2012

Can someone explain this short portion of XHR code?

I'm learning XMLHttpRequest from w3schools. I don't understand the following snippet of code. What does "window.XMLHttpRequest" signify? What makes it true or false? Is this entire if/else structure only there to account for ie6 and ie5, and if so can it all be replaced by one line which reads xmlttp=new XMLHttpRequest()?



 if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}




No comments:

Post a Comment