ASP.NET使用Jquery-Ajax向ashx传递参数中文出现乱码

今天遇到个问题,IE11下Jquery-Ajax向ashx传递参数中文出现乱码,但在谷歌、火狐、360等浏览器中没有乱码的问题,百度了好久最后发现使用escape()对参数值进行处理就可以了;

参考代码:

 1 function SetGoodsName() {
 2 
 3             $("input[id$='GoodsName']").val(val);
 4 
 5             $.ajax({
 6 
 7                 type: "get",
 8 
 9                 url: "../ashx/GetConfigCategory.ashx?GoodsName=" + escape(val) ,
10 
11                 contentType: "application/x-www-form-urlencoded; charset=utf-8",
12 
13                 beforeSend: function (XMLHttpRequest) {
14 
15                 },
16 
17                 success: function (data, textStatus) {                }
18 
19                 },
20 
21                 complete: function (XMLHttpRequest, textStatus) {                },
22 
23                 error: function () {
24 
25                     alert("error");
26 
27                 }
28 
29             }); 
30 
31         }
View Code

 

posted @ 2015-10-28 23:19  longwu.vip  阅读(474)  评论(0编辑  收藏  举报