View Full Version : Problem sending '#' via ajax
The Reverend
06-01-2007, 12:54 AM
I'm new to ajax, so I maybe making a simple mistake. But whenever I send a string from a form that contains a #, that and everything after it never makes it into the database.
Can anyone tell me how to get around this?
glenngv
06-01-2007, 04:46 AM
You should escape() the querystring you pass to the URL.
djmonkey1
06-03-2007, 07:54 PM
This helped me a lot- I was having a problem with linebreaks.
I've noticed that even with escape() the + symbol gets lost (everything else stays the same, but + symbols become spaces). Are there any other symbols that won't work even with escape(), and how can we keep those as well?
glenngv
06-04-2007, 06:57 AM
Use encodeURIComponent instead. Actually, there are 3 different methods of encoding the URL: escape, encodeURI and encodeURIComponent. See the difference here (http://xkr.us/articles/javascript/encode-compare/).
djmonkey1
06-04-2007, 02:51 PM
Thanks for that tip.
In the description of encodeURIComponent() the article states the encodeURIComponent method encodes all characters however near the bottom it states encodeURIComponent() will not encode: ~!*()'
What's up with that?
liorean
06-04-2007, 03:49 PM
Thanks for that tip.
In the description of encodeURIComponent() the article states the encodeURIComponent method encodes all characters however near the bottom it states encodeURIComponent() will not encode: ~!*()'
What's up with that?It means that it encodes all characters that are special in any way in a URI. However, the characters "~", "!", "*", "(", ")" and "'" have no special meaning in URI and don't need to be encoded.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.