Wednesday, December 23, 2009

How to send JSON object using JQUERY to PHP?

After struggling for hours and googling more, finally i succeeded in commincating over Json object. I will share the code:

JS side:

var datastring=JSON.stringify(obj);
$.post('getmessage.php',{data:datastring},function(res){
alert("HIIII"+res);
},"text");
});


php side:

$data=json_decode(stripslashes($_REQUEST['data']),true);
echo $data['page'];
?>