function jsSubmit() {
createXMLHttpRequest();
var province = document.getElementById("province");
//解决客户端向服务器端传输中文乱码
var uri = "AjaxAction?value=" + encodeURI(encodeURI(province.value));
xmlHttp.open("POST", uri, true);
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;")
xmlHttp.onreadystatechange = processResponse;//回调函数啊!
xmlHttp.send(null);
}
function processResponse() {
if(xmlHttp.readyState == 4) {
if(xmlHttp.status == 200) {
var cities = xmlHttp.responseXML.getElementsByTagName("city");
var displaySelect = document.getElementById("city");
displaySelect.innerHTML = null;
for (var i= 0 ;i < cities.length ; i++){
if (i == 0) {
var a= xmlHttp.responseXML.getElementsByTagName("city")[i].firstChild.data;//用firstChild方法,其他方法我用text方法不管用~不知道怎么回事
var op = new Option(a, a, true, true);
} else {
var a= xmlHttp.responseXML.getElementsByTagName("city")[i].firstChild.data;
var op = new Option(a, a);
alert(a);
}
displaySelect.options[i] = op;
}
} else {
window.alert("请求的页面有异常");
}
}
}