[eluser]dianikol85[/eluser]
[quote author="froginvasion" date="1302457669"]I'm trying to get my controller to return a JSON object, but it doesn't
work like it works in all tutorials I can find online (probably pre 2.0 I guess)
some code:
Code:
var u_id = $('input[name=usergroup_id]').val();
$.post('ajax/group/delete_link',{'q_id': $(this).text(),'u_id': u_id},function(data){
alert(data);
});
Code:
function delete_link() {
$id = $this->input->post('u_id');
$result = array('test' => var_dump($id));
echo json_encode($result);
}
It just returns HTML that is the same from the page that is already loaded,
and I don't know why, is there anybody that can help?
Should there be headers set or something, to define that I'm returning
a JSON object?[/quote]
By the way i think you must tell to the $.post that it will accept json
Code:
var u_id = $('input[name=usergroup_id]').val();
$.post('ajax/group/delete_link',{'q_id': $(this).text(),'u_id': u_id},function(data){
alert(data);
},'json');