a.js window.onload = function() {function loadXMLDoc(){var xhr;//浏览器兼容性判断if(window.XMLHttpRequest){//code for IE7+,Firefox,Chrome,Opera,Safarixhr = new XMLHttpRequest();}else{//code for IE5,IE6xhr = new ActiveXObject("Micros
window.onload = function() { function loadXMLDoc() { var xhr; //浏览器兼容性判断 if(window.XMLHttpRequest) {//code for IE7+,Firefox,Chrome,Opera,Safari xhr = new XMLHttpRequest(); } else {//code for IE5,IE6 xhr = new ActiveXObject("Microsoft..XMLHTTP"); } xhr.onreadystatechange = function() { if(xhr.readyState == 4 && xhr.status == 200) { var data = JSON.parse(xhr.responseText); // console.log(data.prodline); for(var i = 0;i < data.length;i++) { console.log(data[i].prodline); // 从数据库获取prodline添加到selectBox; var sel=document.getElementById("Prodline-sel"); var option = new Option(data[i].prodline); sel.options.add(option); } } } xhr.open("GET",'url',true); xhr.send(); } loadXMLDoc(); }