On the client side I have :
var postData = {
"id" : id,
"message" : message
};
console.log(postData);
$.ajax({
type: "POST",
url: "controller/function",
data: postData,
success: function(){
alert(id + ' ' + message);
}
});
This appears to be working properly as I can see the correct post parameters in chrome dev tools. In my codeigniter controller I have tried:
echo 'postid' . $_POST['id'].' '.$_POST['message'];
$postData=$this->input->post('id');
var_dump($postData); exit;
I'm getting:
Message: Undefined index: id
Message: Undefined index: message
boolean(false)
the $_POST
array is empty.
How can I fix this? Thank you for your help