function showRequest() {
//alert('before submit!');
}
function reloadCityArr(data){
var targetSelect=document.getElementById("citySelect");
clearField(targetSelect)
for (var i = 0; i < data.length; i++) {
var opt = document.createElement("OPTION");
opt.text=data[i].title;
opt.value=data[i].value;
targetSelect.add(opt);
}
}
function clearField(targetSelect){
var listlength=targetSelect.length;
for (i=listlength-1;i>=0;i--)
{targetSelect.remove(i);}
}
//1.prototype方式
function addChangeProvince(provinceId) {
var url="__URL__/getCityMap/provinceId/"+provinceId;
new Ajax.Request(url,{
method: 'get',
onComplete: function(transport){
reloadCityArr(eval(transport.responseText));
}});
}
//2.jquery
function addChangeProvince(provinceId) {
var url="__URL__/getCityMap/provinceId/"+provinceId;
$.ajax({
type: "POST",
url: url,
data: "name=John&location=Boston",
dataType:"json",
success: function(data){
reloadCityArr(data);
}
});
}
//3.thinkajax
function complete(data,status,info){
if (status==1){
reloadCityArr(data);
}
}
function addChangeProvince(provinceId) {
var url="__URL__/getCityMap/provinceId/"+provinceId;
ThinkAjax.sendForm('form1',url,complete,'result');
}