0

Angular Code:

sendData(obj){ 
    const userObj = JSON.stringify(obj);  console.log(userObj);
    let headers = new Headers();
    headers.append("Content Type","application/json");
    return this.http.post('http://localhost/codeigniter/index.php/ngGet_Controller/posted', userObj, headers);
}

CoeIgniter(Controller) code:

public function posted(){
    $postdata = file_get_contents("php://input");
    var_dump(json_decode($postdata));
    print_r($this->input->post());
}
gp_sflover
  • 3,460
  • 5
  • 38
  • 48
James
  • 21
  • 3

1 Answers1

0

Please change this line :

headers.append('Content-Type','application/json');

It should be "Content-Type" not "Content Type".

Vivek Doshi
  • 56,649
  • 12
  • 110
  • 122