直接将EL表达式的值赋给var对象时,该EL表达式一定要加上双引号。否则浏览器在解析时,会报错:var对象直接等于一个空白
同样,在JS代码中使用EL表达式也要加上引号
//获取区县列表
function selectDistrict1() {
var mercity ="${merchant.mercity}";
var city_code = $("#mercity").val();
if (city_code == null || city_code == "") {
city_code = mercity
}
var city_code1 = $("#mercity").val();
if (city_code1 == "") {
alert("请选区/县");
return;
}
$.ajax({
type: 'post',
url: '/merchant/getAreaCode',
async: false,
dataType: 'json',
data: {'p_area_code': city_code},
success: function (data) {
var innerHtml = "<option value='' >--请选择区/县--</option>";
var list = data.arealist;
for (var i = 0; i < list.length; i++) {
if (list[i].area_code =="${merchant.merarea}") {
innerHtml += "<option value='" + list[i].area_code + "' selected=selected >" + list[i].name + "</option>";
} else
innerHtml += "<option value='" + list[i].area_code + "'>" + list[i].name + "</option>";
}
$("#merarea").html(innerHtml);
}
});
}