poniedziałek, maja 28, 2007

JSON tu i tam:

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

Brak komentarzy: