function get_value(form){ var scid=sub_class.value;//运算类型号 //--------------------------------------- //使用ajax发送选中的运算类 var url = "query_subject.php?scid="+scid; xmlhttp.onreadystatechange = Content; // var url = "query_subject.php?"; xmlhttp.open("GET",url,true); xmlhttp.send(null); //--------------------------------------- function Content(){ if(xmlhttp.readyState==4){ if(xmlhttp.status==200){ var sel=document.getElementById("sub_name"); var rst=JSON.parse(xmlhttp.responseText);//将字符串转化为数组 for(var i=0; i<rst.length; i++){ var opt=document.createElement('option'); opt.value=rst[i].sid; opt.text=rst[i].s_name; try { sel.add(opt,null); // standards compliant } catch(ex) { sel.add(opt); // IE only } } } else{ alert("你请求的页面错误"); } } } } 本文来自:Linux学习网