November 2017
Intermediate to advanced
386 pages
9h 22m
English
Let's go back a bit to the times when Ajax started to appear. Given those different browsers implemented Ajax calls in distinct fashions, you would always have to code around those differences:
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 re-do the Ajax check for each and every call -- even though the results of the test wouldn't ever change. There's a more efficient way to do so, and it has to do with using functions ...
Read now
Unlock full access