- 显示引用的文字 - Can you post the code where you are opening and sending theXmlHTTPRequest?- Hide quoted text -- Show quoted text - 这就是我正在使用的。谢谢 函数getIndustries() { xmlHttp = GetXmlHttpObject() if(xmlHttp == null) { alert("您的浏览器不支持XMLHttpRequest对象。) 返回 } var url =" getIndustries.aspx" xmlHttp.onreadystatechange = stateChanged xmlHttp.open(" GET" ;,url,true) xmlHttp.send(null) } 函数stateChanged() { if(xmlHttp.readyState == 0) { document.getElementById(" lblResults")。innerHTML = "< img src =''mozilla_blu.gif''alt =''loading..please wait''>" ;; // loading } else if(xmlHttp.readyState == 1) { document.getElementById (< lblResults")。innerHTML ="< img src =''mozilla_blu.gif''alt =''loading..please wait''>" ;; // loading } else if(xmlHttp.readyState == 2) { document.getElementById (< lblResults")。innerHTML ="< img src =''mozilla_blu.gif''alt =''loading..please wait''>" ;; //互动 } else if(xmlHttp.readyState == 3) { document.getElementById (< lblResults")。innerHTML ="< img src =''mozilla_blu.gif''alt =''loading..please wait''>" ;; } else if(xmlHttp.readyState == 4 || xmlHttp.readyState ==" complete") { document.getElementById(" lblResults")。innerHTML ="" ;; //清除以前任何选项的可用列表框 document .choiceForm.available.length = 0; //将分隔的响应拆分为数组 results = xmlHttp.responseText.split("," ;); for(var i = 0; i< results.length; ++ i){ addOption(document.choiceForm.available,结果[i],结果[i]); } } } function addOption(selectbox,text,value) { var optn = document.createEl ement(" OPTION&qu​​ot;); optn.text = text; optn.value = value; selectbox.options.add( optn); } This is what I''m using. Thanks function getIndustries(){xmlHttp=GetXmlHttpObject()if (xmlHttp==null){alert ("Your browser does not support the XMLHttpRequest object.")return}var url="getIndustries.aspx"xmlHttp.onreadystatechange=stateChangedxmlHttp.open("GET",url,true)xmlHttp.send(null)} function stateChanged(){if (xmlHttp.readyState == 0){document.getElementById("lblResults").innerHTML = "<imgsrc=''mozilla_blu.gif'' alt=''loading..please wait''>"; //loading}else if(xmlHttp.readyState == 1){document.getElementById("lblResults").innerHTML = "<imgsrc=''mozilla_blu.gif'' alt=''loading..please wait''>"; //loaded}else if(xmlHttp.readyState == 2){document.getElementById("lblResults").innerHTML = "<imgsrc=''mozilla_blu.gif'' alt=''loading..please wait''>"; //interactive}else if(xmlHttp.readyState == 3){document.getElementById("lblResults").innerHTML = "<imgsrc=''mozilla_blu.gif'' alt=''loading..please wait''>";}else if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){document.getElementById("lblResults").innerHTML = ""; // Clear the available listbox of any previous optionsdocument.choiceForm.available.length = 0; // Split the delimited response into an arrayresults = xmlHttp.responseText.split(","); for (var i=0; i < results.length;++i){addOption(document.choiceForm.available, results[i], results[i]);}}} function addOption(selectbox,text,value ){var optn = document.createElement("OPTION");optn.text = text;optn.value = value;selectbox.options.add(optn);} 这就是我正在使用的。谢谢 函数getIndustries() { xmlHttp = GetXmlHttpObject() if(xmlHttp == null) { alert("您的浏览器不支持XMLHttpRequest对象。) 返回 } var url =" getIndustries.aspx" xmlHttp.onreadystatechange = stateChanged xmlHttp.open(" GET",url,true) xmlHttp.send(null) } 函数stateChanged() { if(xmlHttp.readyState == 0) { document.getElementById(" lblResults")。innerHTML ="< img src =''mozilla_blu.gif''alt =''loading..please wait''>" ;; // loading } else if(xmlHttp.readyState == 1) { document.getElementById (< lblResults")。innerHTML ="< img src =''mozilla_blu.gif''alt =''loading..please wait''>" ;; // loading } else if(xmlHttp.readyState == 2) { document.getElementById (< lblResults")。innerHTML ="< img src =''mozilla_blu.gif''alt =''loading..please wait''>" ;; //互动 } else if(xmlHttp.readyState == 3) { document.getElementById (< lblResults")。innerHTML ="< img src =''mozilla_blu.gif''alt =''loading..please wait''>" ;; } else if(xmlHttp.readyState == 4 || xmlHttp.readyState ==" complete") { document.getElementById(" lblResults")。innerHTML ="" ;; //清除以前任何选项的可用列表框 document .choiceForm.available.length = 0; //将分隔的响应拆分为数组 results = xmlHttp.responseText.split("," ;); for(var i = 0; i< results.length; ++ i){ addOption(document.choiceForm.available,结果[i],结果[i]); } } } 函数addOption(选择框,文本,值) { var optn = document.createElement(" OPTION&qu​​ot;); optn.text = text; optn.value = value; selectbox.options.add(optn); } This is what I''m using. Thanksfunction getIndustries(){xmlHttp=GetXmlHttpObject()if (xmlHttp==null){alert ("Your browser does not support the XMLHttpRequest object.")return}var url="getIndustries.aspx"xmlHttp.onreadystatechange=stateChangedxmlHttp.open("GET",url,true)xmlHttp.send(null)}function stateChanged(){ if (xmlHttp.readyState == 0) { document.getElementById("lblResults").innerHTML = "<imgsrc=''mozilla_blu.gif'' alt=''loading..please wait''>"; //loading } else if(xmlHttp.readyState == 1) { document.getElementById("lblResults").innerHTML = "<imgsrc=''mozilla_blu.gif'' alt=''loading..please wait''>"; //loaded } else if(xmlHttp.readyState == 2) { document.getElementById("lblResults").innerHTML = "<imgsrc=''mozilla_blu.gif'' alt=''loading..please wait''>"; //interactive } else if(xmlHttp.readyState == 3) { document.getElementById("lblResults").innerHTML = "<imgsrc=''mozilla_blu.gif'' alt=''loading..please wait''>"; } else if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById("lblResults").innerHTML = ""; // Clear the available listbox of any previous options document.choiceForm.available.length = 0; // Split the delimited response into an array results = xmlHttp.responseText.split(",");for (var i=0; i < results.length;++i){ addOption(document.choiceForm.available, results[i], results[i]);}}}function addOption(selectbox,text,value ){var optn = document.createElement("OPTION");optn.text = text;optn.value = value;selectbox.options.add(optn);} 只是一个观察,你为什么不设置lblResults的innerHTML 发送请求后立即检查readyState == 4. var url = " getIndustries.aspx" xmlHttp.onreadystatechange = stateChanged xmlHttp.open(" GET",url,true) xmlHttp。 send(null) document.getElementById(" lblResults")。innerHTML ="< img src =''mozilla_blu.gif''alt ='' loading..please wait''>" ;; // loading } 函数stateChanged() { if(xmlHttp.readyState == 4){ //做东西 } } 它会使减少了浏览器的工作量。 Just an observation, why don''t you set the innerHTML of lblResultsright after you send the request and then just check for readyState ==4. var url="getIndustries.aspx"xmlHttp.onreadystatechange=stateChangedxmlHttp.open("GET",url,true)xmlHttp.send(null)document.getElementById("lblResults").innerHTML = "<imgsrc=''mozilla_blu.gif'' alt=''loading..please wait''>"; //loading} function stateChanged(){if(xmlHttp.readyState == 4) {//do stuff}} It will make less work for the browser. 这篇关于AJAX样式处理图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
11-01 00:00