Loading ...
Sorry, an error occurred while loading the content.

Re: Post params don't show up on server side

Expand Messages
  • jameschao122
    Also, I actually have to do the following to get the connection manager to send the request with the correct header: YAHOO.util.Connect.resetDefaultHeaders();
    Message 1 of 8 , May 31, 2007
    • 0 Attachment
      Also, I actually have to do the following to get the connection manager to send the request with the correct header:

           YAHOO.util.Connect.resetDefaultHeaders();
           YAHOO.util.Connect.setDefaultPostHeader(false);
           YAHOO.util.Connect.initHeader('Content-Type', 'application/x-www-form-urlencoded', true);


      --- In ydn-javascript@yahoogroups.com, "jameschao122" <jchao@...> wrote:
      >
      > My post parameters look something like this:
      >
      > "id=1180625935031062&action=get_user_prefs&data=%7B%7D"
      >
      > All of my posts have a parameter for ID, action, and data (sometimes
      > null). And this is exactly what I'm passing in as the fourth parameters.
      >
      > --- In ydn-javascript@yahoogroups.com, "tssha" tsha@ wrote:
      > >
      > > --- In ydn-javascript@yahoogroups.com, "jameschao122" jchao@ wrote:
      > > >
      > > > OK, seems like the problem is with the "Content-Type" header.
      > > >
      > > > By default, it is "application/x-www-form-urlencoded;
      > charset=UTF-8".
      > > >
      > > > When I change it to "application/x-www-form-urlencoded", it works.
      > > >
      > > > Does anybody know if this is the right way to do it or why the
      > default
      > > > value doesn't work??
      > > >
      > > > BTW, this is the code I'm doing to change the header:
      > > >
      > > > YAHOO.util.Connect.setDefaultPostHeader(false);
      > > > YAHOO.util.Connect.initHeader('Content-Type',
      > > > 'application/x-www-form-urlencoded');
      > >
      > > Interesting. Can you show the actual POST message you're sending as
      > > the fourth argument?
      > >
      > > Regards,
      > > Thomas
      > >
      >
    • tssha
      ... Without modifying any of the headers, I used Connection Manager to send the data you provided as follows: var data = encodeURI(
      Message 2 of 8 , May 31, 2007
      • 0 Attachment
        --- In ydn-javascript@yahoogroups.com, "jameschao122" <jchao@...> wrote:
        >
        > My post parameters look something like this:
        >
        > "id=1180625935031062&action=get_user_prefs&data=%7B%7D"
        >
        > All of my posts have a parameter for ID, action, and data (sometimes
        > null). And this is exactly what I'm passing in as the fourth parameters.

        Without modifying any of the headers, I used Connection Manager to
        send the data you provided as follows:

        var data = encodeURI(
        "id=1180625935031062&action=get_user_prefs&data={}"
        );
        var cObj = YAHOO.util.Connect.asyncRequest(
        'POST',
        'post.php,
        callback,
        data);

        The URI post.php will return the results of $_POST, and
        callback.success will write the results to a document. The following
        is the result:
        Array ( [id] => 1180625935031062 [action] => get_user_prefs [data] => {} )

        Can you talk a bit more about how your server entrypoint is configured?

        Regards,
        Thomas
      • jameschao122
        Hi Thomas, I m using Apache::ASP and it seems like the problem lies with that. According to
        Message 3 of 8 , Jun 1 2:06 PM
        • 0 Attachment
          Hi Thomas,

          I'm using Apache::ASP and it seems like the problem lies with that.
          According to
          http://www.nabble.com/Content-type:-application-x-www-form-urlencoded--c\
          harset%3Dutf-8-t1834467.html, it seems like Apache::ASP expects the
          content type to be exactly "application-x-www-form-urlencoded", even
          though the HTTP specs allow for more than that.

          So, I'll just have to live with the workaround I've found. It would be
          nice if there was a better API for changing this though (or am I using
          the APIs incorrectly?). Honestly, a bit surprised that this Content-Type
          header things hasn't been a problem for more people though...

          Anyway, thanks for following up.

          James


          --- In ydn-javascript@yahoogroups.com, "jameschao122" <jchao@...> wrote:
          >
          > Also, I actually have to do the following to get the connection
          manager
          > to send the request with the correct header:
          >
          > YAHOO.util.Connect.resetDefaultHeaders();
          > YAHOO.util.Connect.setDefaultPostHeader(false);
          > YAHOO.util.Connect.initHeader('Content-Type',
          > 'application/x-www-form-urlencoded', true);
          >
          >
          > --- In ydn-javascript@yahoogroups.com, "jameschao122" jchao@ wrote:
          > >
          > > My post parameters look something like this:
          > >
          > > "id=1180625935031062&action=get_user_prefs&data=%7B%7D"
          > >
          > > All of my posts have a parameter for ID, action, and data (sometimes
          > > null). And this is exactly what I'm passing in as the fourth
          > parameters.
          > >
          > > --- In ydn-javascript@yahoogroups.com, "tssha" tsha@ wrote:
          > > >
          > > > --- In ydn-javascript@yahoogroups.com, "jameschao122" jchao@
          wrote:
          > > > >
          > > > > OK, seems like the problem is with the "Content-Type" header.
          > > > >
          > > > > By default, it is "application/x-www-form-urlencoded;
          > > charset=UTF-8".
          > > > >
          > > > > When I change it to "application/x-www-form-urlencoded", it
          works.
          > > > >
          > > > > Does anybody know if this is the right way to do it or why the
          > > default
          > > > > value doesn't work??
          > > > >
          > > > > BTW, this is the code I'm doing to change the header:
          > > > >
          > > > > YAHOO.util.Connect.setDefaultPostHeader(false);
          > > > > YAHOO.util.Connect.initHeader('Content-Type',
          > > > > 'application/x-www-form-urlencoded');
          > > >
          > > > Interesting. Can you show the actual POST message you're sending
          as
          > > > the fourth argument?
          > > >
          > > > Regards,
          > > > Thomas
          > > >
          > >
          >
        • tssha
          ... http://www.nabble.com/Content-type:-application-x-www-form-urlencoded--c ... You have the correct way to turn off the header and setting your own. // If
          Message 4 of 8 , Jun 1 3:07 PM
          • 0 Attachment
            --- In ydn-javascript@yahoogroups.com, "jameschao122" <jchao@...> wrote:
            >
            > Hi Thomas,
            >
            > I'm using Apache::ASP and it seems like the problem lies with that.
            > According to
            >
            http://www.nabble.com/Content-type:-application-x-www-form-urlencoded--c\
            > harset%3Dutf-8-t1834467.html, it seems like Apache::ASP expects the
            > content type to be exactly "application-x-www-form-urlencoded", even
            > though the HTTP specs allow for more than that.
            >
            > So, I'll just have to live with the workaround I've found. It would be
            > nice if there was a better API for changing this though (or am I using

            You have the correct way to turn off the header and setting your own.

            // If you call resetDefaultHeaders here,
            // you'll lose the custom header "X-Requested-With:XMLHttpRequest".
            YAHOO.util.Connect.resetDefaultHeaders();

            // The ability to turn the default POST header was to
            // accommodated those who did not want to use this header
            // as part of their POST request.
            YAHOO.util.Connect.setDefaultPostHeader(false);

            YAHOO.util.Connect.initHeader(
            'Content-Type',
            'application/x-www-form-urlencoded',
            true
            );

            And, if you are interested:
            http://sourceforge.net/tracker/index.php?func=detail&aid=1689122&group_id=165715&atid=836476

            Regards,
            Thomas
          Your message has been successfully submitted and would be delivered to recipients shortly.