Welcome Guest, Not a member yet? Register   Sign In
Jquery $.post JSON returns html
#1

[eluser]froginvasion[/eluser]
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?


Messages In This Thread
Jquery $.post JSON returns html - by El Forum - 04-10-2011, 06:47 AM
Jquery $.post JSON returns html - by El Forum - 04-10-2011, 06:54 AM
Jquery $.post JSON returns html - by El Forum - 04-10-2011, 07:02 AM
Jquery $.post JSON returns html - by El Forum - 04-10-2011, 07:12 AM
Jquery $.post JSON returns html - by El Forum - 04-10-2011, 10:12 AM



Theme © iAndrew 2016 - Forum software by © MyBB