March 16, 2012
to get the values from php to jquery using JSON
Question by user1221098
I am very new to these things .. It might be the easiet question but sitll…..I have to get the date from my mysql database using php and from there to jquery file using JSON to make it work with my jquery plugin. I have put the values in array and used `
$tDate['year']= 2012
$tDate['month']=03
$tDate['day']=06
echo json_encode($tDate);
`
and in my jquery I need to read all these data how do I do it .. have been looking into quite a few websites but have no idea
Answer by Starx
Use $.getjSON()
, if the requirement is only to get the json data.
$.getJSON('your.php', function(data) {
$.each(data, function(key, val) {
alert(val);
});
});