JSON from jQuery to PHP

Posted by enfix on Stack Overflow See other posts from Stack Overflow or by enfix
Published on 2010-04-08T20:03:12Z Indexed on 2010/04/08 20:13 UTC
Read the original article Hit count: 197

Filed under:
|
|
|

I need to pass a JSON object from $.post() jQuery function to PHP page.
I tried this plugin jquery-json, but don't work:

//include jquery.js and jquery.json.js

$(document).ready(function(){ 
   var data = new Object(); 
   data.hello = "Hello"; 
   data.world = "World"; 
   var datajson = $.toJSON(data); 
   $.post('file.php', {data: datajson}, function(res){ 
   alert(res);
   }); 
});

And file.php has this simple line:

<?
var_dump(son_decode($_REQUEST['data'], true));
?>

What's the problem ?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JSON