This must be a simple question and I'm failing to see where is the error, so after reading and trying a lot of things and no advances, I surrender to ask for help!
HTML
...
<form id="FichaCadastral" method="POST">
<input id="CPF" type="text">
...
<input type="submit" value="Submit">
</form>
...
JavaScript
$(function () {
$('#FichaCadastral').on('submit', function (e) {
var opa = {id: 3}; //Simple test data
$.ajax({
url: $(location).attr('pathname'), //I just want to know what webpage posted data
method: 'POST',
type: 'POST',
data: JSON.stringify(opa),
processData: false,
dataType: 'json',
contentType: 'application/json; charset=utf-8',
}); //No success/done/fail callbacks for now, I'm focusing on this problem first
e.preventDefault();
});
}
Node.js
...
server = http.createServer();
server.on('request', function (request, response) {
if (request.method === 'POST') console.log(request.body); //shows 'undefined' in node-dev console
});
I don't know in which code above is the error, because I'm new in all of them.