六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 34|回复: 0

jQuery ajax乱码问题

[复制链接]

升级  20%

2

主题

2

主题

2

主题

童生

Rank: 1

积分
10
 楼主| 发表于 2013-1-29 11:41:08 | 显示全部楼层 |阅读模式
加载完jQuery之后在js中重写params函数
 
 
//二次编码,后台使用URLDecoder.decode()方法解码汉字
jQuery.param=function( a ) {
 var s = [ ];
 function add( key, value ){
  s[ s.length ] = encodeURIComponent(key) + '=' + encodeURIComponent(encodeURIComponent(value));
 };
 // If an array was passed in, assume that it is an array
 // of form elements
 if ( jQuery.isArray(a) || a.jquery )
  // Serialize the form elements
  jQuery.each( a, function(){
   add( this.name, this.value );
  });
 // Otherwise, assume that it's an object of key/value pairs
 else
  // Serialize the key/values
  for ( var j in a )
   // If the value is an array then the key names need to be repeated
   if ( jQuery.isArray(a[j]) )
    jQuery.each( a[j], function(){
     add( j, this );
    });
   else
    add( j, jQuery.isFunction(a[j]) ? a[j]() : a[j] );
 // Return the resulting serialization
 return s.join("&").replace(/%20/g, "+");
}
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表