I've got an object:
var val = {username:'gilbertbw',password:'password',password2:'password',email:'email@email.com',firstname:'gilbert',lastname:'BW',test:true};
I run some validation against it and then post it to my node.js server:
console.log(
$.ajax({
type: 'POST',
url: '/signup',
data: val,
success: function(){console.log('data posted')},
dataType: "json"
})
);
On the server i have tryed just calling the object val:
console.log(val.username);
and pulling it from the post like I normally would:
val = req.param(val,null);
console.log(val.username);
But both times firebug spits out the 500 ISE:
"{"error":{"message":"val is not defined","stack":"ReferenceError: val is not defined at exports.signup (C:\\Users\\Gilbert\\WebstormProjects\\NodeOfGames\\routes\\user.js:37:21)
If i just console.log(val);
it prints null
The line in question is when I try to log val.username to console. How do you recive a posted object in node.js?