Shortest way to create an XMLHttpRequest object

This should work in everything, I think, to get an XMLHttpRequest object for JavaScript in your browser: http = window.XMLHttpRequest ? new window.XMLHttpRequest : (window.ActiveXObject ? new ActiveXObject("MSXML2.XMLHTTP"): null); Of course, this only applies if you’re not using a library to make all this stuff go away, which you maybe should be. But if you’re not, this is a very short way to get the thing you need for Ajax.

More in the discussion (powered by webmentions)

  • (no mentions, yet.)