[SOLVED]Quick ajax XMLHttpRequest referancing.
Posted: Wed Nov 01, 2006 8:58 pm
Hey, I've been beginning to learn Ajax! And so far when setting a variable to reference the XMLHttpRequest, most tuts do something like:
id est, more typing then what I belive to be simple and cross-browser:
It seems to work well for me, just curious as to why most developers prefer the first solution rather then the second? Is it better coding habits? Do most developers prefer the first route? What do you prefer? And is it really cross-browser? Why not?
Post are appreciated.
Code: Select all
var ro;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
ro = new ActiveXObject("Microsoft.XMLHTTP");
}else{
ro = new XMLHttpRequest();
}
Code: Select all
var httpRequest;
(window.ActiveXObject) ? httpRequest = new ActiveXObject("Microsoft.XMLHTTP") : httpRequest = new XMLHttpRequest();
Post are appreciated.