Запрос JSON


* HTML-клиент

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<script type="text/javascript" src="../jquery.min.js"></script>
</head>
<body>

<div id="xxx">SEND REQUEST</div>
    
<script type="text/javascript" >
$(document).ready(function(){
    
    $("#xxx").click(function(){

        $.getJSON("test.php?callback=?",
            function(data) {
                alert(data.testValue);
            });

    });

});
</script>

</body>
</html>

* PHP-сервер

<?php

$callback = $_GET['callback'];

$result = array(
    'testValue' => 'Hello! '.$callback
);

echo json_encode($result);

?>