php - get whole post body within codeigniter controller -
i'm running xmlhttprequest
request this:
var data = json.stringify({ name : "123", id : 12 }); window.console.log("submitting: " + data); var req = new xmlhttprequest(); req.open('post', "http://localhost/index.php/lorem/ipsum", true); req.setrequestheader("content-type", "application/x-www-form-urlencoded"); req.onreadystatechange = function() { if ( req.readystate==4) { window.console.log( "sent back: " + req.responsetext ); } } req.send(data);
as can see there's no name parameter being passed.
now want read json data inside ipsum
function of lorem
controller. how can this? $this->input->post();
returns false :(
use file_get_contents('php://input')
Comments
Post a Comment