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);
});
});
Ve file.php bu basit bir çizgi vardır:
<?
var_dump(json_decode($_REQUEST['data'], true));
?>
Sorun ne?