I save my backbone model with no id therefore it uses the POST protocol to send parameters to my REST API. However I'm unable to catch these parameters, the PUT works just fine and updates the DB but POST method seem to cause problem. One thing I have noticed is that I can catch string parameters but integer parameters are returning as undefined.
my php
if($request_method == 'POST') {
$post_data = file_get_contents("php://input");
$post_data = json_decode($post_data, TRUE);
echo $post_data['name'];
}
backbone code
createdata: function(event){
var newModel = new App.Models.Question({name:$("#_name").val(), surname:$("#_surname").val(), age:$("#_age").val()});
newModel.save({},{
success: function (model, response) {
alert(response.responseText);
},
error: function (model, response) {
alert(response.responseText);
},
wait: true
}
);
console.log(this.myCollection.toJSON());
},