updated
Err i try to see more tutorial and i decided to use $.get() first since its easier and good for starting point..
so this is the script and i think it works correctly except it gives undefined result
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Display Json</title>
<script src="../_js/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$('#jsonButton').click(function()
{
var data = ''
$.get('getJson.php', data, response);
});//end click
});//end ready
function response(data)
{
$('#display').prepend('<p>' + data.name + data.phone + '</p>');
}
</script>
<body>
<div id="display">
<input type="button" id="jsonButton" value="getJson!" />
</div>
</body>
</html>
and this is the getJson.php simple php script that returns simple JSON object :
$data['name'] = 'username';
$data['phone'] = '08989808089';
header('Content-Type: application/json');
echo json_encode($data);
when i click the 'getJson' button, it displays undefined