By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,850 Members | 1,985 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,850 IT Pros & Developers. It's quick & easy.

Plus sign not shown

P: n/a
Hi All

I am using ajax as follows:

var parameters = "groups=" + escape(my*********@gmail.com);
var url="/mydomain/ajaxCall";

if (req != null) {

req.open("POST", url, true);
req.setRequestHeader("Content-type", "application/x-www-form-
urlencoded");
req.send(parameters);
req.onreadystatechange=processResp2;
}

I noticed that inside the ajaxCall the plus (+) sign is replaced with
a space in the string escaped (myemail 10*@gmal.com)

Could someone tell me how to do this correctly?

Thanks
Oct 16 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
souporpo...@gmail.com wrote:
I am using ajax as follows:

var parameters = "groups=" + escape(myemail+...@gmail.com);
var url="/mydomain/ajaxCall";

* * * * if (req != null) {

* * * * * * * req.open("POST", url, true);
* * * * * * * req.setRequestHeader("Content-type", "application/x-www-form-
urlencoded");
* * * * * * * req.send(parameters);
* * * * * * * req.onreadystatechange=processResp2;
* * * * }

I noticed that inside the ajaxCall the plus (+) sign is replaced with
a space in the string escaped (myemail 1...@gmal.com)

Could someone tell me how to do this correctly?
'+' is a reserved character; it is one of the 2 possible ways to
percent-encode a space (the other one is '%20'). You should send '%2B'
if you want to send the plus-sign.

See section 2.2.in RFC 3986:
http://www.ietf.org/rfc/rfc3986.txt

In your code:

parameters = parameters.replace(/\+/g,'%2B');

More info:
http://en.wikipedia.org/wiki/Percent-encoding

Hope this helps,

--
Bart
Oct 16 '08 #2

P: n/a
On Oct 16, 10:07*am, Bart Van der Donck <b...@nijlen.comwrote:
souporpo...@gmail.com wrote:
I am using ajax as follows:
var parameters = "groups=" + escape(myemail+...@gmail.com);
var url="/mydomain/ajaxCall";
* * * * if (req != null) {
* * * * * * * req.open("POST", url, true);
* * * * * * * req.setRequestHeader("Content-type", "application/x-www-form-
urlencoded");
* * * * * * * req.send(parameters);
* * * * * * * req.onreadystatechange=processResp2;
* * * * }
I noticed that inside the ajaxCall the plus (+) sign is replaced with
a space in the string escaped (myemail 1...@gmal.com)
Could someone tell me how to do this correctly?

'+' is a reserved character; it is one of the 2 possible ways to
percent-encode a space (the other one is '%20'). You should send '%2B'
if you want to send the plus-sign.

See section 2.2.in RFC 3986:http://www.ietf.org/rfc/rfc3986.txt

In your code:

* parameters = parameters.replace(/\+/g,'%2B');

More info:http://en.wikipedia.org/wiki/Percent-encoding

Hope this helps,

--
*Bart
Thanks for the clarification. I tried replace as suggested above
and also encodeURI. The plus sign still gets dropped.

I don't know what else to try. Your kind help is appreciated.
Oct 16 '08 #3

P: n/a
so*********@gmail.com wrote:
Bart Van der Donck wrote:
>souporpo...@gmail.com wrote:
>>I am using ajax as follows:
var parameters = "groups=" + escape(myemail+...@gmail.com);
var url="/mydomain/ajaxCall";
if (req != null) {
req.open("POST", url, true);
req.setRequestHeader("Content-type", "application/x-www-form-
urlencoded");
req.send(parameters);
req.onreadystatechange=processResp2;
}
I noticed that inside the ajaxCall the plus (+) sign is replaced with
a space in the string escaped (myemail 1...@gmal.com)
Could someone tell me how to do this correctly?
'+' is a reserved character; [...]
In your code:

parameters = parameters.replace(/\+/g,'%2B');
[...]

I tried replace as suggested above and also encodeURI. The plus sign
still gets dropped.

I don't know what else to try. Your kind help is appreciated.
You could post the code that you are using. The code that you have posted
so far does not run because it is syntactically invalid (you did not quote
the argument of escape); who knows what other typos/omissions are there.

Please trim your quotes to the relevant parts.
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Oct 16 '08 #4

P: n/a
On Oct 17, 12:20*am, "souporpo...@gmail.com" <soup_or_po...@yahoo.com>
wrote:
Thanks for the clarification. I tried replace as suggested above
and also encodeURI. The plus sign still gets dropped.

I don't know what else to try. Your kind help is appreciated.
Use encodeURIComponent() instead of escape() for encoding your POST
data.

/sasuke
Oct 17 '08 #5

P: n/a
On Oct 16, 10:50*pm, sasuke <database...@gmail.comwrote:
On Oct 17, 12:20*am, "souporpo...@gmail.com" <soup_or_po...@yahoo.com>
wrote:
Thanks for the clarification. I tried replace as suggested above
and also encodeURI. The plus sign still gets dropped.
I don't know what else to try. Your kind help is appreciated.

Use encodeURIComponent() instead of escape() for encoding your POST
data.

/sasuke
thank you; the encodeURIComponent worked like a charm

regards
Oct 17 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.