This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum 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
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply 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: 15362
    
    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: 56540
    
  14

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


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Kevin Cornwell
Ranch Hand

Joined: Feb 01, 2005
Posts: 34
Works! Thanks Eric.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: AJAX: posting a ampersand?
 
Similar Threads
Ajax - problem with "%" in xhtml payload - Java error
Multiple Concurrent AJAX Connecitons, HOWTO?
AJAX - setTimeOut problem
Problem of Ajax in Firefox
Xmlhttprequest post error