So, I am reading an AJAX book, and they talk about using an internal function as a way to handle multiple requests. I understand this, but in this bit of code they used, I donβt understand how the XMLHttpRequestObject variable can be used:
if(XMLHttpRequestObject) { XMLHttpRequestObject.open("GET", dataSource); XMLHttpRequestObject.onreadystatechange = function() { if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) { document.getElementById("targetDiv").innerHTML = XMLHttpRequestObject.responseText; delete XMLHttpRequestObject; XMLHttpRequestObject = null; } } XMLHttpRequestObject.send(null); }
My first problem is that they remove the XMLHttpRequestObject , and then, after they are supposedly deleted, they set it to zero. Then, after it supposedly retired and set to null, they use XMLHttpRequestObject.send(null); But how does he do anything when XMLHttpRequestObject is deleted and / or contains no value, since it is also null?
javascript ajax
Justen
source share