How to realize the two-level linkage between province and city in AJAX drop-down box
This article introduces the relevant knowledge of "how to achieve the two-level linkage of provinces and cities in the AJAX drop-down box". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Jsp page code:
The copy code is as follows:
Var xmlHttp=null
/ / create a xmlhttprequest object
If (window.XMLHttpRequest) {
XmlHttp=new XMLHttpRequest ()
} else {
XmlHttp=new ActiveObject ("Microsoft.XMLHTTP")
}
Var url= GetProvince?time= + new Date (). GetTime ()
Function getsheng () {
XmlHttp.open ("post", url,true)
XmlHttp.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded")
XmlHttp.send ()
XmlHttp.onreadystatechange=getprovince
}
Function getprovince () {
If (xmlHttp.readyState==4 & & xmlHttp.status==200) {
Var xmlFile=xmlHttp.responseXML
/ / get the node of the province
Var province=xmlFile.getElementsByTagName ("province")
/ / get the select tag
Var pselect=document.getElementById ("sheng")
/ / cycle to check out the provincial information of the xml file
For (var iTuno Bandi)