# Embedding Question Marks in Query Strings

**URL:** <https://www.ruby-forum.com/t/embedding-question-marks-in-query-strings/115129>\
**Category:** Rails\
**Created:** [September 20, 2007, 9:48pm UTC](https://www.ruby-forum.com/t/embedding-question-marks-in-query-strings/115129 "2007-09-20T21:48:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cwd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/da6949/32.png) [@cwd](https://www.ruby-forum.com/u/cwd)\
**Post date:** [September 20, 2007, 9:48pm UTC](https://www.ruby-forum.com/t/embedding-question-marks-in-query-strings/115129/1 "2007-09-20T21:48:34Z")

</div>

I have an Ajax updater using observe\_field:

 \<%= text\_area\_tag('ubb', nil, :size =\> '60x40') %\> \<%= observe\_field(:ubb, :url =\> {:action =\> 'render\_preview'}, :frequency =\> 0.5, :update =\> 'preview', :with =\> 'ubb') %\>

This all works great until the text in the textarea contains a  
question mark. For example:

Can I use a question mark?

At which point, it seems not to be submittable using the Ajax helpers  
because I get nothing in the params hash.

Anyone had this problem/found workarounds?

Thx

About your application’s environment  
Ruby version 1.8.6 (i686-darwin8.9.1)  
RubyGems version 0.9.4  
Rails version 1.2.3  
Active Record version 1.15.3  
Action Pack version 1.13.3  
Action Web Service version 1.2.3  
Active Resource version 0.9.0  
Action Mailer version 1.3.3  
Active Support version 1.4.2  
Edge Rails revision 224  
Application root /some/directory/in/a/galaxy/far/far/away  
Environment development  
Database adapter mysql  
Database schema version 8

---

<div class="post-metadata">

**Author:** ![cwd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/da6949/32.png) [@cwd](https://www.ruby-forum.com/u/cwd)\
**Post date:** [September 20, 2007, 9:53pm UTC](https://www.ruby-forum.com/t/embedding-question-marks-in-query-strings/115129/2 "2007-09-20T21:53:34Z")

</div>

On 9/20/07, s.ross [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> This all works great until the text in the textarea contains a  
> question mark. For example:
> 
> Can I use a question mark?
> 
> At which point, it seems not to be submittable using the Ajax helpers  
> because I get nothing in the params hash.
> 
> Anyone had this problem/found workarounds?

This is discussed in detail at:

[http://wiki.rubyonrails.org/rails/pages/observe\_field+-+Passing+Parameters](http://wiki.rubyonrails.org/rails/pages/observe_field+-+Passing+Parameters)

---

<div class="post-metadata">

**Author:** ![cwd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/da6949/32.png) [@cwd](https://www.ruby-forum.com/u/cwd)\
**Post date:** [September 20, 2007, 11:13pm UTC](https://www.ruby-forum.com/t/embedding-question-marks-in-query-strings/115129/3 "2007-09-20T23:13:53Z")

</div>

So it is… Thanks. In case anyone else runs into this, if you expect  
any non-URL-safe characters in your Ajax request, use this:

:with =\> “‘text=’ + encodeURIComponent($(‘myfield’).value)”

in your observe\_field method call. Out of the box, all characters are  
passed through unmodified.
