jquery 跳转页面参数中文 URI malformed 错误处理

 

  一,使用 escape() 编码的字符串

 

 url加密传参有时候会出现Uncaught URIError: URI malformed的错误,这是因为你的url中包含了“%”字符,浏览器在对“%”执行decodeURIComponent时报错,正确的解决是将%全部替换为%25再进行传输

url: '/xxx/yyy?key=' + key + "&Account=" + escape(Account) + '&RealName=' + escape(RealName).replace(/%/g,'%25')

 

二,js 接收参数 使用  unescape() 对 escape() 编码的字符串进行解码

   

unescape(request('RealName'))

 

posted @ 2020-07-09 16:56  qingjiawen  阅读(2346)  评论(0编辑  收藏  举报