This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
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


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "AJAX: posting a ampersand?" Watch "AJAX: posting a ampersand?" New topic
Author

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';

AJAX...


in my php...

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

<a href="http://www.kevincornwell.com" target="_blank" rel="nofollow">http://www.kevincornwell.com</A>
Eric Pascarello
author
Rancher

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

Just look at Google for JavaScript encodeURI or JavaScript escape

Eric
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61448
    
  67

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


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

Joined: Feb 01, 2005
Posts: 34
Works! Thanks Eric.
 
 
subject: AJAX: posting a ampersand?