用ajax实现异步刷新,xmlHttp.responseText接到的值不对
用ajax实现异步刷新,xmlHttp.responseText接到的值不对
js:
var xmlHttp;
var json;
function createXmlHttpRequest(){
if(window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest;
}else{
xmlHttpp = new ActiveXObject("Microsoft.XMLHTTP");
}
}
function startRequest(path,id){
createXmlHttpRequest();
switch(id){
case 1:
xmlHttp.onreadystatechange = handleStategetClasstype;
break;
case 2:
xmlHttp.onreadystatechange = handleStategetTeacher;
break;
}
xmlHttp.open("get",path);
xmlHttp.send(null);
}
function getClassinfo(url){
startRequest(url+"/teacherAction_findClasstype.action",1);
}
function getTeacher(url){
var id = document.getElementById("check_type").value();
startRequest(url+"teacherAction_findClassteacher.action",2);
}
function handleStategetClasstype(){
if(xmlHttp.readyState==4){
if(xmlHttp.status==200){
var root = document.getElementById("check_type");
if(root.options.length==1){运动会口号
alert(xmlHttp.responseText);
json = eval('('+xmlHttp.responseText+')');
for(i=0;i
var option = new Option(json[i].classtypeid,json[i].classtypename);
root.add(option);
}
}
}
}
}
jsp中:
|