开发者

Javascript error in Firefox 3.6

开发者 https://www.devze.com 2023-03-10 11:13 出处:网络
I have the following JavaScript code: var xmlHttpReq = getXmlHttpObject(); xmlHttpReq.onreadystatechange=function(){

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 flawle开发者_C百科ss, 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?

0

精彩评论

暂无评论...
验证码 换一张
取 消