I always land into the error function in ajax, what is the problem here?
I want to retrieve a img url stored in the database and append it using jquery to show my img gallery. But before I can do any of this, I have to make sure it always land on the success function, but I always land on error function... so I can not proceed and I am stuck here,
UPDATE:
check the console, it says SyntaxError: missing : after property id on success:function(result)
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)
{
alert("success");
},
error:function()
{
alert("failed"); //it always show the alert failed.
}
});
}
My controller:
function load_design()
{
$this->load->model('design');
$this->load-model('profile');
$user_id = $this->profile->retrieve_userid();
$json = $this->design->load_gallery($user_id->id);
echo json_encode($json);
}
My model:
function load_gallery($user_id)
{
$query = $this->db->query("SELECT * from designs WHERE user_id = '".$user_id."' LIMIT 9");
return $query->result_array();
}