Plus sign not shown

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • souporpower@gmail.com

    #1

    Plus sign not shown

    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.setRequestH eader("Content-type", "applicatio n/x-www-form-
    urlencoded");
    req.send(parame ters);
    req.onreadystat echange=process Resp2;
    }

    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

    #2
    Re: Plus sign not shown

    souporpo...@gma il.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.setRequestH eader("Content-type", "applicatio n/x-www-form-
    urlencoded");
                  req.send(parame ters);
                  req.onreadystat echange=process Resp2;
            }
    >
    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:


    In your code:

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

    More info:


    Hope this helps,

    --
    Bart

    Comment

    • souporpower@gmail.com

      #3
      Re: Plus sign not shown

      On Oct 16, 10:07 am, Bart Van der Donck <b...@nijlen.co mwrote:
      souporpo...@gma il.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.setRequestH eader("Content-type", "applicatio n/x-www-form-
      urlencoded");
                    req.send(parame ters);
                    req.onreadystat echange=process Resp2;
              }
      >
      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.repl ace(/\+/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.

      Comment

      • Thomas 'PointedEars' Lahn

        #4
        Re: Plus sign not shown

        souporpower@gma il.com wrote:
        Bart Van der Donck wrote:
        >souporpo...@gm ail.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.setRequestH eader("Content-type", "applicatio n/x-www-form-
        >>urlencoded" );
        >> req.send(parame ters);
        >> req.onreadystat echange=process Resp2;
        >> }
        >>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.repl ace(/\+/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 bugRiddenCrashP ronePieceOfJunk = (
        navigator.userA gent.indexOf('M SIE 5') != -1
        && navigator.userA gent.indexOf('M ac') != -1
        ) // Plone, register_functi on.js:16

        Comment

        • sasuke

          #5
          Re: Plus sign not shown

          On Oct 17, 12:20 am, "souporpo...@gm ail.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 encodeURICompon ent() instead of escape() for encoding your POST
          data.

          /sasuke

          Comment

          • souporpower@gmail.com

            #6
            Re: Plus sign not shown

            On Oct 16, 10:50 pm, sasuke <database...@gm ail.comwrote:
            On Oct 17, 12:20 am, "souporpo...@gm ail.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 encodeURICompon ent() instead of escape() for encoding your POST
            data.
            >
            /sasuke
            thank you; the encodeURICompon ent worked like a charm

            regards

            Comment

            Working...