-
请求参数,roleName中包含特殊字符"#"
-
发送请求的js代码
static request(param){
let opt = param || {};
opt.url = param.url || '';
opt.async = param.async || true;
opt.data = param.data || null;
opt.success = param.success || function () {};
let requestUrl = opt.url;
requestUrl = this.appendGetParams(requestUrl, opt.data);
requestUrl = encodeURI(requestUrl);
$.ajax({
url: requestUrl,
contentType: 'application/x-www-form-urlencoded;charset=utf-8',
type:"get",
// xhrFields:{
// withCredentials:true
// },
dataType: opt.dataType || 'json'
}).done(function (data) {
...
...
...
});
}
-
原因
encodeURI方法***不会***对下列字符编码 ASCII字母 数字 ~!@#$&*()=:/,;?+'
-
将encodeURI替换为encodeURIComponent
encodeURIComponent方法***不会***对下列字符编码 ASCII字母 数字 ~!*()’,但是会处理"#"
对url进行encode的时候,根据需要选择不同的编码方式
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。