JavaScript function to the rescue! Jul08 '06
Feedback
# (2 of 6): Matthom
2 days, 21 hours after the fact. (Tue 11 Jul 2006, 8:16 AM CST)
Ooh tasty... Even better. I will try that, thanks. I am calling it for each, yes, so that should be better.
# (3 of 6): Wilson
4 months, 3 weeks after the fact. (Tue 28 Nov 2006, 11:21 AM CST)
This blog saved my life. I was implementing an AJAX submit for my site, which involves a WYSIWYG editor. Needless to say, all those quotes, ampersands and html entities totally screwed everything up. I was tearing my hair out trying to find a solution over this and scouring the web like an insane spider with a scouring pad. I was about to give up, and write a lenghtly and inefficient function to replace ALL HTML ENTITIES with a custom tag. Luckily, i found this. Thank god.
# (4 of 6): Matthom
4 months, 3 weeks after the fact. (Tue 28 Nov 2006, 11:27 AM CST)
Yea it really is a lifesaver. Imagine all the extra coding if that function didn't exist. Yuck.
Escaping invalid characters is not how I like to spend my Sunday afternoon.
# (5 of 6): Troy » alivewebs.com.au
5 months, 3 weeks after the fact. (Wed 27 Dec 2006, 10:17 PM CST)
I too will thank you for this.
Until now I have been using encodeURI() but I suddenly found my AJAX cutting a variable off when it had an ampersand (
# (6 of 6): Scott
12 months after the fact. (Sun 08 Jul 2007, 10:45 AM CST)
I'm new to sending things via POST in ajax. And I am building a WYSIWIG type application. ajax is perfect for this type of application, but boy did it not like ampersands. Luckily, google served this page up for me.
Saved me a lot of hassle.
RSS feed for comments on this post
Leave feedback
matthom
is published and produced by Matt Thommes - an independent publishing enthusiast, mobile blogger, content creator, informative writer, web developer from Chicago.
Never one to conform, Matt intends to promote the effect the web has on our lives, in an effort to intensify, instruct, and clarify all that is happening around us.
Isn’t it funny how much mental anguish one goes through, when the answer is right in front of their faces?
You are at the feedback permalink page for: JavaScript function to the rescue!
# (1 of 6): Jennifer Grucza » jennifergrucza.com
2 days, 2 hours after the fact. (Mon 10 Jul 2006, 1:11 PM CST)
Actually, I think you might want encodeURIComponent() instead of encodeURI(), assuming that you’re calling it for each parameter value that you’re adding to the query string.