CodeIgniter Forums
Encoding URL's in JS - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Encoding URL's in JS (/showthread.php?tid=2686)



Encoding URL's in JS - El Forum - 08-19-2007

[eluser]Unknown[/eluser]
I have form data I need to send to a PHP script via an XmlHttpRequest. I don't trust JS validation for a second, so I use encode() to urlencode field values, and let PHP deal with it later.

Problem is, CI for some reason decode's the url, and throws an error.

*I* should be the one to decode the url string, not CI. Any suggestions?


Encoding URL's in JS - El Forum - 08-19-2007

[eluser]Unknown[/eluser]
I don't understand... PHP doesn't decode input from query strings before letting you manipulate it..why does CI? Does anyone else have this problem?


Encoding URL's in JS - El Forum - 08-19-2007

[eluser]gunter[/eluser]
maybe its not CI but an apache setting... I had the problem, that everytime when I passed an urlencoded slash "/" in the url, apache (or something) tried to load this path, instead of seeing it just as a parameter...


Encoding URL's in JS - El Forum - 08-19-2007

[eluser]obiron2[/eluser]
I had the same problem, it seems that it doesn't like it when it tries to decode invalid characters like curly brackets.

I am serialising a JS object so that I can pass it through to CI as a single URL param.

The trick I found was to encode it twice, which makes it a bit long but seems to work.

Obiron