New Formatting for XMLHttpRequest

Recently I decided to try reducing the size of hacking the HTTP request for cross browser support in AJAX. This little snippet has been tested and is working.

// new xml http object
var xmlHttp = new XMLHttpRequest() ? new XMLHttpRequest() :
( new ActiveXObject(“Msxml2.XMLHTTP”) ? new ActiveXObject(“Msxml2.XMLHTTP”) :
( new ActiveXObject(“Microsoft.XMLHTTP”) ? new ActiveXObject(“Microsoft.XMLHTTP”) : null ) );

Recently I decided to try reducing the size of hacking the HTTP request for cross browser support in AJAX. This little snippet has been tested and is working.

I find this new method easier to read and is much more elegant than the method bellow; which is the only method I’ve seen out there.

I know that I am not the only who has tried to shorten this section of code. Let me know what you think or how you handle it yourself.