{"id":592,"date":"2009-12-21T15:40:09","date_gmt":"2009-12-21T20:40:09","guid":{"rendered":"http:\/\/abrammorphew.com\/notes\/?p=592"},"modified":"2009-12-21T15:41:38","modified_gmt":"2009-12-21T20:41:38","slug":"javascript-creating-an-ajax-request","status":"publish","type":"post","link":"http:\/\/abrammorphew.com\/notes\/2009\/12\/21\/javascript-creating-an-ajax-request\/","title":{"rendered":"JavaScript: Creating an XMLHttpRequest object."},"content":{"rendered":"<p>This function returns an XMLHttpRequest() object after evaluating the browser&#8217;s capabilities. I&#8217;m sure there is a way to clean this up a bit as well, but it seems to work thus far. Suggestions are welcome. <\/p>\n<pre class=\"brush:js\">\r\n    function createRequest() {\r\n        try {\r\n            var r = new XMLHttpRequest();\r\n        } catch (trymicrosoft) {\r\n            try {\r\n                 r = new ActiveXObject(\"Msxml2.XMLHTTP\");\r\n            } catch (othermicrosoft) {\r\n                try {\r\n                    r = new ActiveXObject(\"Microsoft.XMLHTTP\");\r\n                } catch (failed) {\r\n                    r = false;\r\n                }\r\n            }\r\n        }\r\n        return r;\r\n    }\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This function returns an XMLHttpRequest() object after evaluating the browser&#8217;s capabilities. I&#8217;m sure there is a way to clean this up a bit as well, but it seems to work thus far. Suggestions are welcome. function createRequest() { try { var r = new XMLHttpRequest(); } catch (trymicrosoft) { try { r = new ActiveXObject(&#8220;Msxml2.XMLHTTP&#8221;); [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[55,53],"class_list":["post-592","post","type-post","status-publish","format-standard","hentry","category-notes","tag-ajax","tag-javascript"],"_links":{"self":[{"href":"http:\/\/abrammorphew.com\/notes\/wp-json\/wp\/v2\/posts\/592","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/abrammorphew.com\/notes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/abrammorphew.com\/notes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/abrammorphew.com\/notes\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/abrammorphew.com\/notes\/wp-json\/wp\/v2\/comments?post=592"}],"version-history":[{"count":3,"href":"http:\/\/abrammorphew.com\/notes\/wp-json\/wp\/v2\/posts\/592\/revisions"}],"predecessor-version":[{"id":595,"href":"http:\/\/abrammorphew.com\/notes\/wp-json\/wp\/v2\/posts\/592\/revisions\/595"}],"wp:attachment":[{"href":"http:\/\/abrammorphew.com\/notes\/wp-json\/wp\/v2\/media?parent=592"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/abrammorphew.com\/notes\/wp-json\/wp\/v2\/categories?post=592"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/abrammorphew.com\/notes\/wp-json\/wp\/v2\/tags?post=592"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}