- Serwer - PHP
- $i = array(
array("id" => 1, "name" => "sumardi"),
array("id" => 2, "name" => "hassan"),
array("id" => 3, "name" => "ruby")
); - echo json_encode($i);
- Zwróci - [{"id":1,"name":"sumardi"},{"id":2,"name":"hassan"},{"id":3,"name":"ruby"}]
- Klient - JS
- for(var i = 0; i < json.length; i++)
{
console.info(json.id + " " + json.name);
}
Brak komentarzy:
Prześlij komentarz