Home >Backend Development >PHP Tutorial >javascript - Chinese conversion problem in url address

javascript - Chinese conversion problem in url address

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-06 13:52:191348browse

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

Reply content:

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

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn