Why is send
so often called as
xhr.send(null)
instead of
xhr.send()
?
W3, MDN, and MSDN all state that it's optional. Furthermore, the ActiveX control doesn't seem to need the argument:
hr=pIXMLHTTPRequest.CreateInstance("Msxml2.XMLHTTP.6.0");
SUCCEEDED(hr) ? 0 : throw hr;
hr=pIXMLHTTPRequest->open("GET", "http://localhost/books.xml ", false);
SUCCEEDED(hr) ? 0 : throw hr;
hr=pIXMLHTTPRequest->send(); // <-- this line
SUCCEEDED(hr) ? 0 : throw hr;
The practice of send(null)
goes back at least as far as 2005 in Google Maps, but being minified, there's no explanation:
Y.asynchronousTransform = function (qc, vb, kc, Nc, Ba) {
if (m.type == 3) return;
var cc = Y.getCached(kc);
if (cc) {
cc.transformToHTML(qc, vb);
if (Nc) Nc();
return
}
var yc = qa.create(Ba);
var sa = Xd.create();
nd('<a href="' + kc.xmlEscape() + '">' + kc.xmlEscape() + "</a>", 0);
sa.open("GET", kc, true);
sa.onreadystatechange = function () {
if (sa.readyState == 4) {
if (yc.isValid()) {
try {
var Db = sa.responseXML;
var cc = Y.create(Db);
Y.cache(kc, cc);
cc.transformToHTML(qc, vb);
if (Nc) Nc()
} catch (b) {}
}
}
};
sa.send(null)
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…