Welcome Guest, Not a member yet? Register   Sign In
Sending json to script file
#1

[eluser]Hantar[/eluser]
I query the db in my model like so

Code:
function graphRate($userid, $courseid){
    $query = $this->db->get('tblGraph');
        return $query->result();
}

My controller gets data back from my model and I json encode it like so

Code:
if($query = $this->rate_model->graphRate($userid, $courseid)){
    $data['graph_json'] = json_encode($query);      
}
$this->load->view('graph', $data);

And thats returns me a json object like so

Code:
[
{"id":"1","title":"myTitle","score":"16","date":"2013-08-02"},
{"id":"2","title":"myTitle2","score":"17","date":"2013-09-02"},
{"id":"3","title":"myTitle3","score":"18","date":"2013-10-02"}
]

In my view graph I'm loading an js file

Code:
[removed][removed]

Now I want to use $data that is being sent from my controller to my view, to my external script.js to use as labels and data to feed my chart. But How do I get that Json data to my external script.js so I can use it?


Messages In This Thread
Sending json to script file - by El Forum - 08-06-2013, 04:46 AM
Sending json to script file - by El Forum - 08-06-2013, 04:55 AM
Sending json to script file - by El Forum - 08-06-2013, 04:57 AM
Sending json to script file - by El Forum - 08-06-2013, 04:58 AM
Sending json to script file - by El Forum - 08-06-2013, 05:00 AM
Sending json to script file - by El Forum - 08-06-2013, 05:02 AM
Sending json to script file - by El Forum - 08-06-2013, 05:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB