S
S
Sergey Zhukov2015-09-21 19:24:51
PHP
Sergey Zhukov, 2015-09-21 19:24:51

How to solve the problem of special characters in the address bar?

All the best!
Please help me get by with a little bloodshed:
I use this wonderful plugin https://github.com/Mikhus/jsurl
Allows you to manipulate the URl.
Everything works until the page is reloaded:
I fill in the array (dynamically), but here I’ll show it simply with static

url.query.materials = [1,2,3];
history.pushState(null, null, url);

I get this URL:
/gg?materials[]=1&materials[]=2&materials[]=3

Everything is great, attributes are removed and added.
But, as soon as I just do a page reload and try to change the same thing, I get:
/gg?materials%5B%5D[]=1&materials%5B%5D[]=2&materials%5B%5D[]=3&materials[]=4

While there is an idea, it’s just stupid to make a replacement in location.href . But this is somehow ugly, there must be some way.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Ineshin, 2015-09-21
@IonDen

Unfortunately, you only need to work with address strings through encodeURI and encodeURIComponent

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question