Modify your addressbook.php web service to return data in JSON format.
You should use these HTML and
JS files for this version.
For example, if a GET request is made without any parameters, you should return
{"names": ["name1", "name2", ...]}
And if a GET request is made with the name parameter, you should return
{"name": "some_name", "address": "some_address"}
You can try out the service here.
header('Content-type: application/json');
if (isset($_GET["name"])) {
$name = $_REQUEST["name"];
$ret = array("name" => $name, "address" => "");
foreach ($lines as $line) {
$info = explode(",", $line);
if ($info[0] == $name) {
$ret["address"] = $info[1];
}
}
print json_encode($ret);
} else {
$names = array();
foreach ($lines as $line) {
$info = explode(",", $line);
array_push($names, $info[0]);
}
print json_encode(array("names" => $names));
}