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?

Était-ce utile?

La solution

Try rawurlencode() instead of urlencode

Autres conseils

You solution is good. You could use

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

But it is more of the same.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top