js URL中文传参乱码

js:

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

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


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









原文地址:https://www.cnblogs.com/hellozg/p/6228689.html