如何给Ajax的回调函数传参数? 1 function GetNewWFLineIDs(count,newLineIds) 2 { 3 var url = '../servlet/net.blogjava.lzqdiy.TestAjax'; 4 var cmd='cmd=GetNewWFLineID'; 5 var param='param=<Params><IDCount>'+count+'</IDCount></Params>'; 6 getReqObject(); 7 if(req) 8 { 9 10 req.open("POST",url, false); 11 req.onreadystatechange=function(){saveLineIDs(newLineIds);}//给回调函数传参数 12 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 13 req.setrequestheader("cache-control","no-cache"); 14 var param1=encodeURI(cmd+"&"+param); 15 var param2=encodeURI(param1); 16 req.send(param2); 17 } 18 }回调函数如下: function saveLineIDs(newLineIds) { if (req.readyState == 4) { if (req.status == 200) { var res=req.responseXML; var ids=res.getElementsByTagName("WFLineID"); for(var i=0;i<ids.length;i++) { if(isIE) { newLineIds.push(ids[i].childNodes[0].data); } if(isFirefox) { newLineIds.push(ids[i].childNodes[0].nodeValue); } } } } }