PHP code=>`
<?php
//request data from the database
//code here to connect to database and get the data you want
/* Example JSON format
{
"item1": "I love jquery4u",
"item2": "You love jQuery4u",
"item3": "We love jQuery4u"
}
*/
//return in JSON format
echo "{";
echo "item1: ", json_encode($item1), "\n";
echo "item2: ", json_encode($item2), "\n";
echo "item3: ", json_encode($item3), "\n";
echo "}";
?>
JS=>
$(document).ready(function(){
//attach a jQuery live event to the button
$('#getdata-button').click(function(){
$.get('json-data.php', function(data) {
//alert(data); //uncomment this for debug
//alert (data.item1+" "+data.item2+" "+data.item3); //further debug
$('#showdata').html("<p>item1="+data.item1+" item2="+data.item2+" item3="+data.item3+"</p>");
});
});
});
Please i've asked earlier too and i wasnt including details so this time ive included the whole sample when included Apart from this my console gives no error. Thank You `