Codeigniter get not working
This in the controller ajax
function get_class_posts()
{
echo json_encode($this->input->get());
}
Straight from the console line in chrome:
$.get("/ajax/get_class_posts",{user_id:2},function(data){window.vv = data})
RESPONSE >> 开发者_StackOverflow中文版OBJECT
window.vv
RESPONSE >> "{"\/ajax\/get_class_posts":""}"
when I do $.post(...)
and $this->input->post()
it works as it should (i.e. returns user_id:2
)
Have you allowed the GET array to pass in Codeigniter. In your config/config.php make sure you have ...
$config['allow_get_array'] = TRUE;
Otherwise you will not have the GET variables.
精彩评论