This project is archived and is in readonly mode.

#404 ✓invalid
CakePHPUser

Request.JSON doesn't automatically convert send data to JSON format

Reported by CakePHPUser | October 4th, 2008 @ 02:57 PM | in 2.0 (closed)

Before Version 1.2 Request.JSON would automatically convert the object you put in send() to a JSON data structure and put "json=" before it. With 1.2 I have to send data like this:

var jsonRequest = new Request.JSON({ url: 'handler.pl',

                                    onComplete: function(jsonObj) {
                                      .... },
                                    method: 'post' }
                                ).send("json="+JSON.encode(jData));

instead of

var jsonRequest = new Request.JSON({ url: 'handler.pl',

                                    onComplete: function(jsonObj) {
                                      .... },
                                    method: 'post' }
                                ).send(jData);

The old way is much more elegant... was this done on purpose?

Comments and changes to this ticket

  • Valerio

    Valerio October 5th, 2008 @ 12:22 PM

    • State changed from “new” to “invalid”

    Yes. That was not a good behavior: you should send your "object" just as postdata.

    The way it works now:

    JS Object -> PHP Array ($_POST)

    The way it used to work:

    JS Object -> JS String -> PHP String -> PHP Array

    Same start and end, but less steps involved. Unfortunately, the underlying PHP code has to change too: it no longer requires you to convert $POST['json'] to an array with json_decode, but instead it just uses $POST, as it should be.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

People watching this ticket

Pages