XMLHTTP中Status

XMLHTTP中Status

CODE1:
function createXmlHttp() {
        // create XMLHTTP Object
    if (typeof XMLHttpRequest != "undefined") {
        var oXmlHttp =  new XMLHttpRequest();
    } else {
        var oXmlHttp =  new ActiveXObject("MSXML2.XMLHttp.5.0");
    }

    // initial XMLHTTP Object
    oXmlHttp.open("get", "GetCustomerData.php", true);
    oXmlHttp.onreadystatechange = function () {
                if (oXmlHttp.readyState == 4) {
                        if (oXmlHttp.Status == 200) {
                                displayCustomerInfo("success");
                        } else {
                                displayCustomerInfo("An error occurred: " + oXmlHttp.statusText); //statusText is not always accurate
                        }
                        alert("oXmlHttp.status is " + oXmlHttp.Status);
                }
        };
        oXmlHttp.send(null);
}

function displayCustomerInfo (sText) {
    var divCustomerInfo = document.getElementById("divCustomerInfo");
        divCustomerInfo.innerHTML = sText;
}

<div id="divCustomerInfo"></div>

问题就出在if (oXmlHttp.Status == 200) { 这行里面,只要在IE里才能显示正确(success),而firefox以及oper里显示错误信息 ,
(一改)而当把if (oXmlHttp.Status == 200) {这行中的Status开头的大写改成小写后,注意alert("oXmlHttp.status is " + oXmlHttp.Status);此行的Status不改.当我再次运行时,firefox以及oper现在可以正确的显示(success)了,但是用alert弹出的对话框却显示"oXmlHttp.Status undefined".
(二改)当我也把alert("oXmlHttp.status is " + oXmlHttp.Status);中的Status改成小写后一切都OK了--页面能正确的显示,alert弹出的对话框也能正确显示"oXmlHttp.Status 200"
所以我就由此判断出IE 对(Status)的大小写不敏感,而firefox以及oper对大小写都敏感

当时我在看书的时候,书上还有这么一段话:
Important
The statusText property isn't implemented in Opera and sometimes returns an inaccurate description in other browsers. You should never rely on statusText alone to determine if an error occurred.
开始我还以为是statusText弄错了,可是后来调试才知道。所以以后该坚持的时候还是要坚持寻根问底,不要用书上面的话做挡箭牌。刨根问底了,可能如书上所说的,是statusText弄错了,但是如果是自己的失误,那现在又可以小收获一笔了,不是吗(自我告戒的话)

有时候书未必就是对的。可能这本书只考虑到ie。
如履薄冰