php+ajax无刷新实现省、地、市三级联动

htmlheadmeta;varrequestType=;functioncreateXMLHttpRequest(){if(window.ActiveXObject){xmlHttp=newActiveXObject(Microsoft.XMLHTTP);}elseif(window.XMLHttpRequest){xmlHttp=newXMLHttpRequest();}}functionqueryCity(citycode){createXMLHttpRequest();type=city;varurl=data.php?provincecode=+citycode;xmlHttp.open(GET,url,true);xmlHttp.onreadystatechange=handleStateChange;xmlHttp.send(null);}functionqueryArea(citycode){createXMLHttpRequest();type=area;varurl=data.php?citycode=+citycode;xmlHttp.open(GET,url,true);xmlHttp.onreadystatechange=handleStateChange;xmlHttp.send(null);}functionhandleStateChange(){if(xmlHttp.readystate==4){if(xmlHttp.status==200){if(type==city){showcity();}elseif(type=area){showarea();}}}}functionshowcity(){document.getElementById(city).innerHTML=xmlHttp.responseText;document.getElementById(area).innerHTML=;}functionshowarea(){document.getElementById(area).innerHTML=xmlHttp.responseText;}/script/headbody?$conn=mysql_connect(localhost,root,2328725);mysql_select_db(novel);mysql_query(setnames’utf8′);$sql=select*fromprovince;$result=mysql_query($sql);echofromid=’form1’/n;echoselectid=’province’onchange=’queryCity(this.options[this.selectedIndex]澳门新葡亰网站注册,.value)’/n;echooptionvalue=’-1’selected请选择省份/option/n;while($row=mysql_fetch_row($result)){echooptionvalue=’$row[1]’$row[2]/option/n;}echo/select/n;echospanid=’city’/span/n;echospanid=’area’/span/n;echo/form/n;?/body/html