Try rawurlencode()
instead of urlencode
How to decode in JavaScript a URL encoded in PHP?
-
19-09-2022 - |
문제
I'm using PHP to encode a Url and after that I'm using the Url in Javascript for filling the title of a Bootstrap modal
I have something like this when I encode in PHP
#task/2013-12-23/517/1+task+for+Some+other+test+apartment+in+Lviv+on+December+23rd+2013
but the decode in Javascript is expecting this
#task/2013-12-23/517/1%20task%20for%20Some%20other%20test%20apartment%20in%20Lviv%20on%20December%2023rd%202013
I dont want to do it like this
var title = "1+task+for+Some+other+test+apartment+in+Lviv+on+December+23rd+2013";
title.replace(/\+/g," ");
Anyone knows a better solution?
해결책
다른 팁
You solution is good. You could use
var decodedTitle = title.replace("+"," ");
But it is more of the same.
제휴하지 않습니다 StackOverflow