Bouncing JSON requests - Javascript
2007-06-10
Simple measure of round-trip times for bouncing a JSON request off a server. The server-side script (bounce.php) is:
<?php
$a = array(
'date' => date('Y.m.d H:i:s'),
'uname' => php_uname()
);
echo json_encode($a);
?>
The code to generate a JSON request (in bounce.html) is in effect:
var o = JSON.makeGET("bounce.php");
o.onResponse = function(v) {
// use v
};
o.sendGET();
Where v is the JSON response (click bounce.php to see a response).