ajax刷新问题,求大神解决

 function kuaisuxuanren(x){ 
                    alert("111111111111ppppppppppppp"+x)
                    var xmlhttp = new XMLHttpRequest;
                    xmlhttp.onreadystatechange = function () {
                        if(xmlhttp.readyState==4){
                            if(xmlhttp.status==200){
                                var str = xmlhttp.responseText; 
                                var obj = eval("("+str+")");
                                var list = obj.jsonData;
                                var grouplist = list["var"];
                                //alert(grouplist.length);
                                for(var i=0;i<grouplist.length;i++){                                
                                    var email = grouplist[i].email; 
                                    //alert("00000000000"+email);                               
                                    var name = grouplist[i].name;
                                    var deptName = grouplist[i].deptName;
                                    //var div = document.createElement("div");
                                    //div.setAttribute("class", "background-color: red;");divcss
                                    var li = document.createElement("li");
                                    li.setAttribute("style", "margin-left:85px;height:20px;font-size:14px;");
                                    var label = document.createElement("label");
                                    label.setAttribute("style","width:150%;");
                                    label.setAttribute("for","radiochoose");
                                    label.setAttribute("id","ren");
                                    label.setAttribute("onclick","queren()");
                                    label.innerText = name;                                                         
                                    var ul = document.createElement("ul"); 
                                    //div.appendChild(ul);                      
                                    persons.appendChild(li);
                                    li.appendChild(label);
                                //  alert(deptName);                        
                                    }           
                            }               
                        }
                    }

                    var sd = sid.value; 
                    var arr = new Array();
                    arr = document.getElementById(x).value.split(';');
                    //alert("111111111111111111gggg"+arr.length);
                    var keyword = arr[arr.length-1];
                    var url = "http://mail.ah.chinamobile.com/webmail/service/addr/user?func=addr:searchAddrUser&sid="+sd+"&rnd=0.2907288070686717,744";
                    var entity = "{\"total\":15,\"keyword\":\""+keyword+"\"}";                  
                    xmlhttp.open("POST",'<%=mobile_hostName%>/MobilePlatform/rest/datasource/dsInvoke.do?method=getPageData&dataSourceId=ahcmcc.mdyj.mdyj_kuaisuxuanren&sessionId=<%=session.getAttribute("sessionId")%>&sid='+sd+'&_internal_request_entity='+entity,true);
                    xmlhttp.send(null); 


        }
    x参数会改变,每个x刷新一次,但是后面的值总是覆盖前面的值,怎么解决呀。。。代码如上、、

后面的值总是覆盖前面的值是个什么意思?没看明白哪里会覆盖

把不想被覆盖的值设置在函数外面,做全局变量就好了

每次刷新行之前先将原有数据清除即可啊!

var a = 0 ;
function caculate(x){
a = x;
}
caculte(1);
alert(a);

这个时候a就变为1了啊! 你不要在function中将需要改变的值前面用var 进行声明就好了!