Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
需要使用主干在codeigniter视图中显示结果json文件_Json_Codeigniter_Backbone.js - Fatal编程技术网

需要使用主干在codeigniter视图中显示结果json文件

需要使用主干在codeigniter视图中显示结果json文件,json,codeigniter,backbone.js,Json,Codeigniter,Backbone.js,我的API函数是 function student_GET() { $response = $this->viewList(); $this->response($response); } function viewList() { $this->load->model('model_student'); $response = $this->model_student->getStudents(); retur

我的API函数是

function student_GET() {
    $response = $this->viewList();
    $this->response($response);
}

function viewList() {
     $this->load->model('model_student');
     $response = $this->model_student->getStudents();
     return $response;
}
我的模型是

function getStudents() {
    $sql= "SELECT * FROM students;
    $query = $this->db->query($sql);
    if ($query->num_rows() > 0) {
        return $query->result();
    } else {
    return NULL;
    }
}
API工作正常,结果json数据

[
  {
    "id": "5",
    "subject": "English",
    "score": "93",
    "name": "john"
  },
  {
    "id": "9",
    "subject": "Maths",
    "score": "75",
    "name": "jack"
   }
]

我需要使用
backbone.js
请帮助在视图中显示这些结果详细信息。

这是一个适用于backbone和任何js库的示例: “结果”是您的数据来自请求

success: function(results) {
   for (var i = 0; i < results.length; i++) {
            var tempData=[];
                        tempData[0] = results[i].get('subject');
                        tempData[1] = results[i].get('score');
                        tempData[2] = results[i].get('name');
                        tempData[3] = results[i].get('id');
                       // or tempData[4] = results[i].id;
  }
}

这是一个适用于主干网和任何JS库的示例: “结果”是您的数据来自请求

success: function(results) {
   for (var i = 0; i < results.length; i++) {
            var tempData=[];
                        tempData[0] = results[i].get('subject');
                        tempData[1] = results[i].get('score');
                        tempData[2] = results[i].get('name');
                        tempData[3] = results[i].get('id');
                       // or tempData[4] = results[i].id;
  }
}

需要使用collection和model在视图中显示json值

需要使用collection和model在视图中显示json值

当我可以从jsonData.get(“score”)获取数据时,我使用parse.com api及其主干示例。我做了下面的一个例子。当我可以从jsonData.get(“score”)获取数据时,我使用parse.com api及其主干示例。我在下面举一个例子。你给出的例子甚至没有得到准确的值。你能给你的完整代码添加一个链接吗,我看一下。还有json下载链接,如果可能的话。你给出的例子甚至没有得到准确的值。你能给你的完整代码添加一个链接吗,我看一下。如果可能的话,还有json下载链接
[
    {
        "name": "Tim Cook",
        "title": "CEO",
        "background": "Tim Cook is the CEO of Apple and serves on its Board of Directors."  
    },
    {
        "name": "Angela Ahrendts",
        "title": "Senior Vice President of retail and online stores",
        "background": "Angela Ahrendts is Apple's senior vice president of retail and online stores, reporting to CEO Tim Cook."
    },
    {
        "name": "Eddy Cue",
        "title": "Senior Vice President of Internet Software and Services",
        "background": "Eddy Cue is Apple's senior vice president of Internet Software and Services, reporting to CEO Tim Cook."
    },
    {
        "name": "Craig Federighi",
        "title": "Senior Vice President of Software Engineering",
        "background": "Craig Federighi is Apple's senior vice president of Software Engineering, reporting to CEO Tim Cook."
    },
    {
        "name": "Jonathan Ive",
        "title": "Senior Vice President of Design",
        "background": "London-born designer Jonathan Ive is Apple's senior vice president of Design, reporting to CEO Tim Cook. "
    }
]