Search code examples
javascriptphptwitter-bootstrapbackbone-routing

How to decode in JavaScript a URL encoded in PHP?


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?


Solution

  • Try rawurlencode() instead of urlencode