It's not a secret anymore!
The moose likes HTML, CSS and JavaScript and the fly likes AJAX: posting a ampersand? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "AJAX: posting a ampersand?" Watch "AJAX: posting a ampersand?" New topic

AJAX: posting a ampersand?

Kevin Cornwell
Ranch Hand

Joined: Feb 01, 2005
Posts: 34
I can't seem to post a '&' in a post from via AJAX. Everything else works fine.

in my form..
oFrm.my_shout.value = 'foo & bar';


in my php...

[ June 19, 2006: Message edited by: Kevin Cornwell ]

<a href="" target="_blank" rel="nofollow"></A>
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
You need to escape/encode it.

Just look at Google for JavaScript encodeURI or JavaScript escape

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63862

Note that this is not something that is Ajax specific -- when formatting a URL by hand you must encode parameter values.

[Asking smart questions] [About Bear] [Books by Bear]
Kevin Cornwell
Ranch Hand

Joined: Feb 01, 2005
Posts: 34
Works! Thanks Eric.
I agree. Here's the link:
subject: AJAX: posting a ampersand?
It's not a secret anymore!