分享你我的心得.
共乘一片美好网络.

jq提交汉字get出乱码问题

jq提交汉字后被URL编码,自动解码后乱码,是由于编码不统一与UTF-8模式文件存在,那么就得需要转换一下

在js中利用 escape 转一下编码

<script>

function DateDemos(id,guige)
{
$.get(“/sc/gouwuche/”, {
idss :id,
guige:escape(guige)
}, function (data){
if (data==0)
{
location.href = ‘/sc/gouwuche/’;
}
if (data==1)
{
location.href = ‘/sc/gouwuche/’;
}
if (data==2)
{
alert(“请登录!”);location.href = ‘/login/login.htm’;
}
if (data==3)
{
alert(“加入购物车失败!”);
}
});
}

</script>

在接收参数页面比如asp页面进行解码即可

<%Function vbsUnEscape(str)
dim i,s,c
s=””
For i=1 to Len(str)
c=Mid(str,i,1)
If Mid(str,i,2)=”%u” and i<=Len(str)-5 Then
If IsNumeric(“&H” & Mid(str,i+2,4)) Then
s = s & CHRW(CInt(“&H” & Mid(str,i+2,4)))
i = i+5
Else
s = s & c
End If
ElseIf c=”%” and i<=Len(str)-2 Then
If IsNumeric(“&H” & Mid(str,i+1,2)) Then
s = s & CHRW(CInt(“&H” & Mid(str,i+1,2)))
i = i+2
Else
s = s & c
End If
Else
s = s & c
End If
Next
vbsUnEscape = s
End Function

guige=vbsUnEscape(request(“guige”))

%>

赞(0)
未经允许不得转载:小叶白龙博客 » jq提交汉字get出乱码问题
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址