Codeigniter Angularjs http post not working

By Hardik Savani | February 22, 2016 | | 37582 Viewer | Category : PHP jQuery AngularJS Codeigniter


Sometimes, you face problem you can't get post data using $this->input->post(), when you fire $http.post() using AngularJS or Jquery. I also face this issue, i can't receive post value when i fire $http.post in AngularJS, But i found how to receive post data or json data in Codeigniter controller. in following example through you can solve your problem:

public function store()

{

$this->load->database();

$_POST = json_decode(file_get_contents('php://input'), true);

$posts = $this->input->post();

$this->db->insert('posts', $posts);

}



Hardik Savani
My name is Hardik Savani. I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.
Follow Me: Github Twitter
***Do you want me hire for your Project Work? Then Contact US.