Adding ajax loading gif to script

dzasp

New Member
Thanks for looking, I have the below script that updates a series of drop down boxes, populated depending on the users previous answer. Data comes from SQL tables. I was wondering how I could add an Ajax loading gif to each drop down while the data is loading. I hope this makes sense, if not please ask.\[code\]<script language="javascript">var xmlhttpfunction selectmanu(){xmlhttp=GetXmlHttpObject();if (xmlhttp==null) { alert ("Your browser does not support XMLHTTP!"); return; } document.form1.mtype.style.background = "#FFFFFF" var id=document.form1.mtype.value;var url="selectmanu.php";url=url+"?id="+id;/*url=url+"&sid="+Math.random();*/xmlhttp.onreadystatechange=stateChanged;xmlhttp.open("GET",url,true);xmlhttp.send(null);}function stateChanged(){if (xmlhttp.readyState==4) { document.getElementById("abc").innerHTML=xmlhttp.responseText; }}function GetXmlHttpObject(){if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari return new XMLHttpRequest(); }if (window.ActiveXObject) { // code for IE6, IE5 return new ActiveXObject("Microsoft.XMLHTTP"); }return null;}function selectmodel(){xmlhttp=GetXmlHttpObject();if (xmlhttp==null) { alert ("Your browser does not support XMLHTTP!"); return; } document.form1.manu.style.background = "#FFFFFF" var id=document.form1.manu.value;var url="selectmodel.php";url=url+"?id="+id;xmlhttp.onreadystatechange=stateChanged1;xmlhttp.open("GET",url,true);xmlhttp.send(null);}function stateChanged1(){if (xmlhttp.readyState==4) { document.getElementById("modspan").innerHTML=xmlhttp.responseText; }}function validate(){if(document.form1.mtype.valuehttp://stackoverflow.com/questions/2108284/=='0'){document.form1.mtype.style.background = "#FF0000"return false;}else if(document.form1.manu.valuehttp://stackoverflow.com/questions/2108284/=='0'){document.form1.manu.style.background = "#FF0000"return false;}else if(document.form1.model.valuehttp://stackoverflow.com/questions/2108284/=='0'){document.form1.model.style.background = "#FF0000"return false;}return true;}function mset(){if(document.form1.model.value!='0'){document.form1.model.style.background = "#FFFFFF"}}</script>\[/code\]Cheers,B.
 
Back
Top