Posting multidimensional JSON

View: New views
1 Messages — Rating Filter:   Alert me  

Posting multidimensional JSON

by Jette Derriche-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am using this function to post data to the server:

---------------------------------------
function ajaxCall(jsnParams) {
  var jsnResult,
  strUrl = 'ajax.php',
  strHandle = 'json';
 
  jsnResult = dojo.rawXhrPost({
    url: strUrl,
    sync: true,
    handleAs: strHandle,
    content: jsnParams,
    load: function(data,ioArgs) {
      return data;
    },
    error: function(data,ioArgs) { return data; }
 });
 return eval(jsnResult.results[0]);
}
---------------------------------------

When using the function, this works:

----------------------
var jsnResult = ajaxCall({"var1":"val1","var2":"val2"});
----------------------

At the server side, I get $_POST['var1'] and $_POST['var2'] as expected.

But now I need to send a multidimensional JSON:

----------------------
var jsnResult =
ajaxCall({"var1":"val1","var2":"val2","var3":{"var3a":"val3a"}});
----------------------

I would expect to get $_POST['var3']['var3a'] set to the 'val3a' value
but instead I just get "[object Object]". This is the output of the PHP
var_dump() function:

-----------------------
array (3) {
  ["var1"]=>
  string(4) "val1"
  ["var2"]=>
  string(4) "val2"
  ["var3"]=>
  string(15) "[object Object]"
}
-----------------------

Can you tell me why that is?

/Jette
 


_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://docs.dojocampus.org
Dojo-interest@...
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest