Welcome Guest, Not a member yet? Register   Sign In
Encoding URL's in JS
#1

[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?
#2

[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?
#3

[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...
#4

[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




Theme © iAndrew 2016 - Forum software by © MyBB