var urlAddr = '<%=basePath%>getSpecialtyUserAction.action?dept=' + $(this).val();
urlAddr = encodeURI(urlAddr);
urlAddr = encodeURI(urlAddr);
$.ajax({
url :urlAddr,
type:'get',
dataType:'json',
ContentType:'application/json; charset=utf-8',
success:function(data){
//var datas = eval('(' + data.teachers +')'); //需要将字符串转换成数组进行处理
var datas = eval(data.teachers);
for(i=0; i< datas.length; i++){
alert(datas[i].gzbh + " " + datas[i].name);
}
alert("人员数目: " + datas.length);
},
error:function(msg){
Notice("加载教职员工数据异常!");
}
});
需要注意,对你所传递的参数进行处理,在前端进行encodeURI两次,在后台界面中使用dept = java.net.URLDecoder.decode(dept,"UTF-8"); 来对编码进行处理,注意在页上设置你的编码格式
原文链接:https://www.f2er.com/ajax/166876.html