解决Ajax向jsp传参中文乱码的问题
通过找资料,确实解决了,但是知其然,还不知其所以然.....
try {
$.ajax({
url : "getdevicelist.jsp",
type : "post",
data : "DeviceType=" + encodeURI(encodeURI(iValue)) + "&InstallLocation=" +encodeURI(encodeURI(m_szDeviceInstallLocation)),
dataType : "html",
error : function() {
alert("Error");
},
success : function(msg) {
$("#DeviceName").empty();
msg = $.trim(msg);
if (msg != "") {
$(msg).appendTo("#DeviceName"); // 添加下拉框的option
if(document.getElementById("DeviceName").options.length > 0)
{
setTimeout(function() { $("#DeviceName option[value='"+ m_szDeviceName+"']").attr("selected",true);}, 1);
}
}
},
complete : function() {
// CompleteLogUser();
}
});
} catch (err) {
// alert(err.description);
}
szInstallLocation = request.getParameter("InstallLocation");
String ttt = java.net.URLDecoder.decode(szInstallLocation,"UTF-8"); ///Over
szInstallLocation = szInstallLocation.trim();
posted on 2012-03-05 16:54 java课程设计例子 阅读(263) 评论(0) 编辑 收藏 举报