<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
</head>
<body>
<script>
$(document).ready(function(){
$.getJSON('getfile.php', function(data) {
alert(data);
});
});
</script>
</body>
</html>
my php file-->getfile.php
<?php
$json='{"info":{"name":"ram","lname":"katara"}}';
$json = json_decode($json,true);
print_r($json);
?>
my output is-->
Array ( [info] => Array ( [name] => ram [lname] => katara ) )
How can i print this json data into my html page using javascript or ajax jquery.
echo '{"info":{"name":"ram","lname":"katara"}}';.PHP) and not json data as you're decoding itjson_decode(). The real question here is What would you like to do with the json data you receive from your php script?