Hi,
When you pass a string into `Ajax.Request`, you're taking
responsibility for properly encoding it. Since you're not specifying a
different encoding, the default is URI encoding, in which the '#'
should be encoded as %23.
To correctly encode your parameters, encode each component (e.g., the
name or value) using `encodeURIComponent`. Since you're just using a
single string, not a series of name=value items, for you that would
be:
new Ajax.Request('/some_url', {
method: 'get',
parameters: encodeURIComponent(token)
});
You'll want to ensure that whatever is receiving it decodes it
correctly as well. I mention that since you're not using named
parameters, and so I suspect you have server-side code looking
directly at the query string, which will be encoded. (If your server-
side code were dealing with a framework of some kind that handles
named parameters for you, that framework would decode for you.)
If you were doing named parameters, like "foo=bar", you would do the
component parts, not the whole thing:
params = encodeURIComponent("foo") + "=" + encodeURIComponent("bar");
new Ajax.Request('/some_url', {
method: 'get',
parameters: params
});
(You rarely see people encoding the name portion, because most of the
time they're simple names that don't need encoding -- e.g., in teh
above, "foo" is the same before and after encoding and so I could have
omitted it. I couldn't if "foo" had any interesting characters in it.)
HTH,
--
T.J. Crowder
Independent Software Engineer
tj / crowder software / com
www / crowder software / com
On Apr 14, 6:52 am, Sunild <[email protected]> wrote:
> New to Prototype/JS, etc. I have the following code.
>
> var token = 'id1#a12345' + "," + 'id2#e6789'
>
> new Ajax.Request('/some_url', {
> method: 'get',
> parameters: token });
>
> Using FF 3.6.16 and Firebug 1.5.4, the params get truncated at the #
> symbol and only 'id1' is sent in the request. I've tried escaping the
> # with
>
> token = token.replace(/#/g, "\\#"); with the similar results. Now 'id1\
> \' is sent. How do I send the # symbol as part of the request
> parameters ?
--
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en.