문제

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?

도움이 되었습니까?

해결책

Try rawurlencode() instead of urlencode

다른 팁

You solution is good. You could use

var decodedTitle = title.replace("+"," "); 

But it is more of the same.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top