# AJAX call - weird special character problem

**URL:** <https://www.ruby-forum.com/t/ajax-call-weird-special-character-problem/120665>\
**Category:** Rails\
**Created:** [November 19, 2007, 5:06pm UTC](https://www.ruby-forum.com/t/ajax-call-weird-special-character-problem/120665 "2007-11-19T17:06:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![TFTFTF](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/2acd7d/32.png) [@TFTFTF](https://www.ruby-forum.com/u/TFTFTF)\
**Post date:** [November 19, 2007, 5:06pm UTC](https://www.ruby-forum.com/t/ajax-call-weird-special-character-problem/120665/1 "2007-11-19T17:06:16Z")

</div>

I’m using a form\_remote\_tag with a collection:

\<%= select\_tag “fields[]”,  
options\_from\_collection\_for\_select(@fields, :keyname, :keyname),  
:multiple =\> true,  
:size =\> “10”%\>

which works fine so far. The content of @fields looks something like  
this:  
MC1\_OS\_CPU\_%iowait  
MC1\_OS\_CPU\_%idle  
MC1\_OS\_CPU\_%user  
[…]

When submitting the form with a single value selected from the select  
field, everything works fine. params:“fields”=\>[“BCURD01\_OS\_CPU\_  
%user”]

But when selecting multiple values, the params look like this:  
fields"=\>[“MC1\_OS\_CPU\_%2525idle”, “MC1\_OS\_CPU\_%2525iowait”,  
“MC1\_OS\_CPU\_%2525user”]

Notice the 2525s. This only occours with special chars like “%” or “&”  
inside the values.

Any ideas how to fix this?

Thanks,  
Thomas

---

<div class="post-metadata">

**Author:** ![TFTFTF](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/2acd7d/32.png) [@TFTFTF](https://www.ruby-forum.com/u/TFTFTF)\
**Post date:** [November 19, 2007, 5:22pm UTC](https://www.ruby-forum.com/t/ajax-call-weird-special-character-problem/120665/2 "2007-11-19T17:22:16Z")

</div>

It seems to be a prototype.js issue. The POST request looks as  
follows:  
fields%5B%5D=BCURD01\_OS\_CPU\_%252525system&fields%5B%5D=BCURD01\_OS\_CPU\_  
%252525user

So looks like it’s a bad idea to have %-signs inside the strings.  
Putting ’ ’ around the strings didn’t help.

But there must be a way to escape them or something?
