简体   繁体   中英

Javascript error in Firefox 3.6

I have the following JavaScript code:

 var xmlHttpReq = getXmlHttpObject();
    xmlHttpReq.onreadystatechange=function(){
        if (xmlHttpReq.readyState == 4) {
            var res =xmlHttpReq.response;     
            var result = res.split(',');           
            if (document.getElementById("shoppingCardAjax")!=null){      
            document.getElementById("shoppingCardAjax").innerHTML = overAllPayment + result[1];
            }
    }

on Chrome this code works flawless, but on Mozilla 3.6 I'm getting error:

res is undefined
var result = res.split(','); 

Why? What's the difference?

xmlHttpReq.response should be xmlHttpReq.responseText

PS: Why don't you use a nice lib like jQuery instead of doing all the XHR stuff manually?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM