XMLHttpRequest Question:
Download Job Interview Questions and Answers PDF
How do I get the XMLHttpRequest object?
Answer:
Depending upon the browser...
if (window.ActiveXObject) {
// Internet Explorer
http_request = new ActiveXObject("Microsoft.XMLHTTP");
}
else if...
if(window.XMLHttpRequest)
{
xmlhttpobj=new XMLHttpRequest();
return xmlhttpobj;
}
else
{
try
{
xmlhttpobj=new ActiveXObject("Microsoft.XMLHTTP");
}catch(e)
{
xmlhttpobj=new ActiveXObject("Msxml2.XMLHTTP");
}
}
}
if (window.ActiveXObject) {
// Internet Explorer
http_request = new ActiveXObject("Microsoft.XMLHTTP");
}
else if...
if(window.XMLHttpRequest)
{
xmlhttpobj=new XMLHttpRequest();
return xmlhttpobj;
}
else
{
try
{
xmlhttpobj=new ActiveXObject("Microsoft.XMLHTTP");
}catch(e)
{
xmlhttpobj=new ActiveXObject("Msxml2.XMLHTTP");
}
}
}
Download XHR2 Interview Questions And Answers
PDF
Previous Question | Next Question |
What is Ready State? | Explain what is JSON? |