js URL中文传参乱码

 

js:

   var searchVal = encodeURIComponent($.trim($('#js_search_val').val()));//搜索的值 encodeURIComponent() 函数可把字符串作为 URI 组件进行编码。

window.location.href = gUrl + '/name/' + searchVal;//跳转


php:
urldecode(); 将 URL 编码后字符串还原成未编码的样子 









posted @ 2016-12-28 11:11  太菜  阅读(125)  评论(0编辑  收藏  举报