Console.log(result) shows undefined when I open my console in firefox. Is there something wrong with the returned json?
Here is my script:
function load_contents(track_page) {
$('#loading').show();
$.ajax({
url:'<?php echo base_url('gallery/load_design');?>',
type:'GET',
dataType:'json',
success:function(result) {
console.log(result);
alert("success");
},
error:function(result) {
console.log(result);
alert("failed");
}
});
}
My controller:
public function load_design() {
$this->load->model('design');
$this->load-model('profile');
$user_id = $this->profile->retrieve_userid();
$result = $this->design->load_gallery($user_id->id);
header('Content-Type: application/json');
echo json_encode($result);
}
My model:
function load_gallery($user_id) {
$data = array();
$query = $this->db->query("SELECT * from designs WHERE user_id = '".$user_id."' LIMIT 9");
return $query->result();
}