Connecting Tech Pros Worldwide Help | Site Map

Plus sign not shown

souporpower@gmail.com
Guest
 
Posts: n/a
#1: Oct 16 '08
Hi All

I am using ajax as follows:

var parameters = "groups=" + escape(myemail+100@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 100@gmal.com)

Could someone tell me how to do this correctly?

Thanks
Bart Van der Donck
Guest
 
Posts: n/a
#2: Oct 16 '08

re: Plus sign not shown


souporpo...@gmail.com wrote:
Quote:
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
souporpower@gmail.com
Guest
 
Posts: n/a
#3: Oct 16 '08

re: Plus sign not shown


On Oct 16, 10:07*am, Bart Van der Donck <b...@nijlen.comwrote:
Quote:
souporpo...@gmail.com wrote:
Quote:
I am using ajax as follows:
>
Quote:
var parameters = "groups=" + escape(myemail+...@gmail.com);
var url="/mydomain/ajaxCall";
>
Quote:
* * * * if (req != null) {
>
Quote:
* * * * * * * req.open("POST", url, true);
* * * * * * * req.setRequestHeader("Content-type", "application/x-www-form-
urlencoded");
* * * * * * * req.send(parameters);
* * * * * * * req.onreadystatechange=processResp2;
* * * * }
>
Quote:
I noticed that inside the ajaxCall the plus (+) sign is replaced with
a space in the string escaped (myemail 1...@gmal.com)
>
Quote:
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.
Thomas 'PointedEars' Lahn
Guest
 
Posts: n/a
#4: Oct 16 '08

re: Plus sign not shown


souporpower@gmail.com wrote:
Quote:
Bart Van der Donck wrote:
Quote:
>souporpo...@gmail.com wrote:
Quote:
>>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
sasuke
Guest
 
Posts: n/a
#5: Oct 17 '08

re: Plus sign not shown


On Oct 17, 12:20*am, "souporpo...@gmail.com" <soup_or_po...@yahoo.com>
wrote:
Quote:
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
souporpower@gmail.com
Guest
 
Posts: n/a
#6: Oct 17 '08

re: Plus sign not shown


On Oct 16, 10:50*pm, sasuke <database...@gmail.comwrote:
Quote:
On Oct 17, 12:20*am, "souporpo...@gmail.com" <soup_or_po...@yahoo.com>
wrote:
>
Quote:
Thanks for the clarification. I tried replace as suggested above
and also encodeURI. The plus sign still gets dropped.
>
Quote:
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
Closed Thread