您的位置:首页 > Web前端 > JavaScript

解决Ajax向jsp传参中文乱码的问题

2012-03-05 16:54 351 查看
通过找资料,确实解决了,但是知其然,还不知其所以然.....

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();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: