Question

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?

Was it helpful?

Solution

Try rawurlencode() instead of urlencode

OTHER TIPS

You solution is good. You could use

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

But it is more of the same.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top