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

javascript - Chinese conversion problem in url address

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-06 13:52:19
Original
1347 people have browsed it

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>
Copy after login
Copy after login

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>
Copy after login
Copy after login

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

Related labels:
Statement of this Website
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
Latest Issues
What are JavaScript hook functions?
From 1970-01-01 08:00:00
0
0
0
What is JavaScript garbage collection?
From 1970-01-01 08:00:00
0
0
0
c++ calls javascript
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template