//重写jQuery.param方法,1.4之后有个序列化,直接加trueescape代替encodeURIComponent
encodeURIComponent会以utf-8编码,在gbk编码下,可不可以以gbk进行编码呢?
如果还在打encodeURIComponent主意的话,那不好意思,encodeURIComponent只会utf-8编码,并没有其他api进行其他编码;不过,别担心,看看下面:
encodeURIComponent,它是将中文、韩文等特殊字符转换成utf-8格式的url编码。
escape对0-255以外的unicode值进行编码时输出%u****格式,其它情况下escape,encodeURI,encodeURIComponent编码结果相同。
哈哈,看到希望吧?没错,就是用escape代替encodeURIComponent方法,不过必须注意:
escape不编码字符有69个:*,+,-,.,/,@,_,0-9,a-z,A-Z
encodeURIComponent不编码字符有71个:!, ',(,),*,-,.,_,~,0-9,a-z,A-Z
使用了escape之后必须对加号进行编码,否则,当内容含有加号时候会被服务端翻译为空格。
终于知道解决办法了,重写jquery代码:
详细出处参考:http://www.jb51.net/article/25051.htm
jQuery.param=function( a ) {
var s = [ ];
var encode=function(str){
str=escape(str);
str=str.replace(/+/g,"%u002B");
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余1页未读,立即下载