I'm using jquery and jason sending data to another contoller, but when I send the data, I check it in fire bug and it's fine, It sends it correctly but in the target page, when I var_dump the $_REQUEST or $_POST is returns null.
I'm using codeigniter by the way.
This my jquery code:
<script type="text/javascript">
function GetMovieLanguageCategory(Language)
{
$.ajax({
type: "POST",
contentType: "application/json",
url: "/admin/movie/get_language_category",
data: JSON.stringify({"Language":Language}),
success: function(Data)
{
alert(Data);
},
failure: function(ErrorMsg) {
alert(ErrorMsg);
},
});
}
</script>
And in my Controller:
var_dump($_REQUEST);
//var_dump(json_decode($_POST['Language']));
And it returns:
array(0) {}
Am I wrong somewhere?
failureshould beerrorcontentType: "application/json"but didn't help!$_REQUESTonly gets populated when you send a query string as either POST or GET. You are not doing that. You need to read the raw POST body:$postBody = file_get_contents('php://input'); echo $postBody;.