January 2020
Intermediate to advanced
470 pages
11h 13m
English
Let's go back a bit in time to when Ajax started to appear. Given that different browsers implemented Ajax calls in distinct fashions, you would always have to code around these differences. The following code shows how you would go about implementing an Ajax call by testing several different conditions:
function getAjax() { let ajax = null; if (window.XMLHttpRequest) { // modern browser? use XMLHttpRequest ajax = new XMLHttpRequest(); } else if (window.ActiveXObject) { // otherwise, use ActiveX for IE5 and IE6 ajax = new ActiveXObject("Microsoft.XMLHTTP"); } else { throw new Error("No Ajax support!"); } return ajax;}
This worked, but implied that you would redo the Ajax check for each and every call, even though the results ...
Read now
Unlock full access