...

View Full Version : Problem sending '#' via ajax



The Reverend
05-31-2007, 11:54 PM
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, 03:46 AM
You should escape() the querystring you pass to the URL.

djmonkey1
06-03-2007, 06: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, 05: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, 01: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, 02: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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum