I have been working on a mini AJAX and ColdFusion powered Chat application so that I can help people debug their code in a real-time way. One bug that has popped up early on is that "+" symbols are getting lost. From what I narrowed down, the "+" is not even making it into the database. The error is on the way In, not the way Out.
Here is a demo. I created a simple page that took one URL parameter with a "+" symbol and then I dump out the URL structure. Here is the URL:
Here is the URL struct:
// Escape the URL parameters for this AJAX url request. escape( objParams[ strKey ] // Escape the "+" manually. ).replace( new RegExp( "\\+", "g" ), "%2B" )
Want to use code from this post? Check out the license.
Ben, I read your blog regularly and found this on the web when searching for a chat client for a site that i'm working on. I like the idea and will read the post later when I get back. One thing I want to recommend is the form serializer from http://www.massimocorner.com. I have used some of Massimo's stuff in the past and his code is super clean and elegant, you may want to give that a look.
I tried to chat by clicking on the link and for some reason the cursor kept losing focus. I literally had one hand on the mouse and kept clicking back in and the other to type with.
Not sure if you knew about that little bug.
Look forward to talking to you soon!
Thanks heaps for this post, I nailed an issue with UTF8 characters in my web system development that had lingered for years.
Testiment to the value of blogging...
Glad to help out.
Thanks for the post, finally got Google to give me the result I wanted.
How annoying this is and I came across this due to an email address.
Thanx a ton, Ben and Erki.. u guys saved me hours of embarrasment.. :)
No problem - also, don't forget to check out the follow up post to this which talks about the function, encodeURIComponent():
It makes this post less relevant (and your life easier!).