文本丢失加号和连接号的问题
因为采用data:字符串这种形式,+和&是jquery分隔参数的分隔符,所以会丢失,解决方法就是把text文本中的+和&替换掉,用js里面的encodeURIComponent编码,为了省事,直接写出编码替换..
1.参数最好使用json的格式:{"abc":"cde","efg":123} ,例如:
var params = { width:1680, height:1050 };
var data = jQuery.param(params);
注意param方法会自动转换(encodeURIComponent)编码方式是将字符串转换为UTF-8的方式来传输
decodeURIComponent($.param(params));
2.文本丢失加号和连接号的问题('+','&'丢失)
因为采用AJAX参数是采用JSON格式如data:str字符串这种形式这样+和&是jquery分隔参数的分隔符,所以会丢失,解决方法就是把text文本中的+和&替换掉
function FixJqText(str) {
var tempstr = str.replace(/\+/g, "%2B");
tempstr = tempstr.replace(/\&/g, "%26");
return tempstr;
}
或者用encodeURIComponent编码
tempstr = tempstr.replace(/\&/g, "%26");
return tempstr;
}
或者用encodeURIComponent编码