ajax级联省市区

前端之家收集整理的这篇文章主要介绍了ajax级联省市区前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
/*级联省——》市*/
	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",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)); 
		          }
			});
		}
	}
原文链接:https://www.f2er.com/ajax/163898.html

猜你在找的Ajax相关文章