Home >Backend Development >PHP Tutorial >javascript - Chinese conversion problem in url address
The client uses js to send requests
How to use js to process data
Use php to process data in the background
js I use
<code>encodeURI(keyword)</code>
php
urldecode
Still not working
location.href=encodeURI("gallery.html?keyword=" this.searchword);
PHP cannot search directly with $GET['keyword']
location.href="gallery.html?keyword=" encodeURIComponent(this.searchword);
Similarly not working
The client uses js to send requests
How to use js to process data
Use php to process data in the background
js I use
<code>encodeURI(keyword)</code>
php
urldecode
Still not working
location.href=encodeURI("gallery.html?keyword=" this.searchword);
PHP cannot search directly with $GET['keyword']
location.href="gallery.html?keyword=" encodeURIComponent(this.searchword);
Similarly not working
js also has a function encodeURIComponent
. In addition, php does not need to use urldecode
to accept parameters, just $_GET['keyword']
It may be an encoding problem, please try to unify the encoding
To encode parameters, you should use encodeURIComponent. To encode the entire uri, use encodeURI