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'];
?>

No comments:

Post a Comment

Why India Hasn’t Built Its GPT Moment (Yet)

India has the world’s third-largest startup ecosystem, a thriving developer base, and a mobile-first population larger than the US and Europ...