JSON format for jQuery UI Autocomplete

前端 未结 6 905
青春惊慌失措
青春惊慌失措 2021-02-19 05:20

The documentation for jQuery UI Autocomplete states that the source property can be set to a URL that returns the suggested items in JSON format. However, it doesn

6条回答
  •  走了就别回头了
    2021-02-19 05:43

    using firebug we can see this format for json

    [{"id":"Podiceps nigricollis","label":"Black-necked Grebe","value":"Black-necked Grebe"}]
    

    I used json_encode

    $a[$x] = array("id" => $row["id"],"label"=>$row["label"],"value"=>$row["value"]);
    }
    //echo JSON to page
        $response =  json_encode($a);
    echo $response;
    

提交回复
热议问题