`

jQuery Ajax 传中文参数出现乱码(传值,乱码)

 
阅读更多
解决方案一:(修改jquery.js)
修改前:
ajaxSettings: {
url: location.href,
global: true,
type: "GET",
contentType: "application/x-www-form-urlencoded",
processData: true,
async: true,
                .....
修改后:
ajaxSettings: {
url: location.href,
global: true,
type: "GET",
contentType: "application/x-www-form-urlencoded;charset=UTF-8",
processData: true,
async: true,
                .....
调用的时候:
$.ajax({
        contentType: "application/x-www-form-urlencoded;charset=UTF-8",
        ......
只需要简单的将JQuery的代码加以修改,加上charset=UTF-8就可以了,这样不需要改变改什么web.config或什么在页面中改编码什么的了,也不需要用escapc(str)再在服务端解码。英文怎么传递,中文也怎么传递。
分享到:
评论
1 楼 sfc235300 2012-10-25  
假如我传的一个参数为name=李连杰
后台request.getParameter("name")的值仍然是乱码,怎么回事?

相关推荐

Global site tag (gtag.js) - Google Analytics