ajax级联省市区

时间:2021-08-17 12:28:31
/*级联省——》市*/
function showCity(cityGid){
var entity = new Object();
entity.gid = cityGid;
if(cityGid!=""){
$("#cityGid").empty();
$.ajax({
async:false,
url: "<%=APP_ACCESS_NAME%>/common/foodsNvrInputedAction!showCity.action",
type: "POST",
dataType: "json",
data: "jsonParam="+JSON.stringify(entity),
success: function( data ) {
var result = JSON.parse(data);
var option='';
for (var i = 0; i < result.length; i++) {//动态添加
option +='<option value="'+result[i].gid+'">'+result[i].name+'</option>';
}
$("#cityGid").append($(option));
}
});
}
}
/*级联市——》区*/
function showCounty(countyGid){
var entity = new Object();
entity.gid = countyGid;
if(countyGid!=""){
$("#countyGid").empty();
$.ajax({
async:false,
url: "<%=APP_ACCESS_NAME%>/common/foodsNvrInputedAction!showCounty.action",
type: "POST",
dataType: "json",
data: "jsonParam="+JSON.stringify(entity),
success: function( data ) {
var result = JSON.parse(data);
var option='';
for (var i = 0; i < result.length; i++) {//动态添加
option +='<option value="'+result[i].gid+'">'+result[i].name+'</option>';
}
$("#countyGid").append($(option));
}
});
}
}