get whole post body within codeigniter controller

I'm running XMLHttpRequest request like 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 you can see there's no name for parameter being passed.

now I want to read that JSON data inside ipsum function of lorem controller. How can I do this? $this->input->post(); returns false :(

Answers


Use file_get_contents('php://input')


Need Your Help

jQuery mobile refresh button

jquery ajax jquery-mobile

I am having problems when I add new content to the database the pages are not updated. So I was thinking of adding a refresh button.

How do i write JOOQ select query for the following MSSQL query?

hibernate spring-mvc jooq

How do I convert below select query from MSSQL to JOOQ format?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.