我使用笨,因爲我需要從控制器如何從控制器解析JSON值來查看的jQuery/AJAX
這裏解析JSON字符串是我的代碼:
public function autosuggest_country(){
$query = $this->db->query("SELECT country, count(country) as `Total` FROM list GROUP BY country");
//echo"<pre>"; print_r($query->result());
echo json_encode($query->result()); }
而且作爲入門
[{"country":"Colombia","Total":"1"},{"country":"Estonia","Total":"1"},{"country":"India","Total":"13"},{"country":"Mexico","Total":"1"},{"country":"USA","Total":"1"}]
輸出,並且我不知道如何將這種類型的JSON解析輸出到$ .getJSON()數據參數?
由於提前
其alr一個json對象。你不需要再解析它。 –