Just came to the same conclusion. My intent was to actually send a stringified version of the JSON object (so im using json2.js from http://www.json.org). None the less, thanks Eric!
On Jul 16, 4:51 am, "Erik Beeson" <[EMAIL PROTECTED]> wrote: > HTTP parameters are key/value pairs. If you have an object like: > > var json = { > foo: 'bar', > boo: 'far' > > }; > > It will get converted into HTTP parameters foo=bar and boo=far. > > In your example, you have one key, "Request", and its value is an object. > Converting the value (a JavaScript object) to a string yields "[object > Object]", which is what you're seeing. If you were expecting to get complex > PHP objects on your server side, you're mistaken about how HTTP parameters > work :) > > Basically, make your JSON object only one level deep and you should be fine. > > Hope it helps. > > --Erik > > On 7/15/08, jlb <[EMAIL PROTECTED]> wrote: > > > > > According to the jQuery docs, the data option (in $.ajax) is supposed > > to accept a string or an object (which it then converts to a query > > string). It appears as though its not converting my object: > > > My Javascript is: > > > var json = { > > "Request" : { > > "action" : "doSomething", > > "params" : {"id":"123"} > > } > > }; > > > $.ajax({ > > type: "POST", > > url: WEB_DOMAIN + "/api.php", > > data: json > > }); > > > In api.php contains: > > > <?php var_dump($_REQUEST['Request']); ?> > > > Which outputs: > > > string(15) "[object Object]" > > > Does anyone know what I'm doing wrong?