Welcome Guest, Not a member yet? Register   Sign In
Is my controller being called by JQuery at all?
#1

[eluser]capypara[/eluser]
Hi guys, i want to call a php method in my controller using jquery, and display the sql results. My code doesnt give me any errors (not even in firebug) but it does not work; my sql data does not get shown in my alert box.

Code:
//JS
function update()
{
    $.post(site_url+"mycontroller/method1", {'room_name': $('#room_name').val()},
      function(data){alert(data);}, "json");}
}

//PHP
    function method1()
    {
     $x = 0;
     $user_list = "";
        $room = $this->input->post('room_name');
        $users = $this->my_model->get_users($room);

        foreach ($users->result() as $row)
        {
            $user_list[$x] = $row->user_name;
            $x++;
        }

        return $user_list;
    }

I tested method1 separately and it works fine. I tried using echos and var_dumps in method1 but in that case nothing gets displayed, not even alert. If i take away my echos and var_dumps alert is displayed but the result is null. Firebug shows that the parameters are posted properly to method1. What am i doing wrong?




Theme © iAndrew 2016 - Forum software by © MyBB