I've a table in the database that contains a field which is type Date. If I try to insert a date from postman through the API like this:
{
"registerDate" : "2014-06-02"
}
It works, but then I try to do it from javascript with jquery taking the value from an input in the format YYYY-MM-DD or even giving to the variable the value "2014-06-02" it inserts a NULL value in the database.
var user = new Object();
user.registerDate = $('#register_date').val();
createUser(url, type, JSON.stringify(user), function(user){
});
or
var user = new Object();
user.registerDate = "2014-06-02";
createUser(url, type, JSON.stringify(user), function(user){
});
Where createUser is:
function createUser(url, type, user, success){
$.ajax({
url:url,
type: 'POST',
crossDomain : true,
contentType : type,
data : user
})
.done(function (data, status, jqxhr) {
success(user);
})
.fail(function (jqXHR, textStatus) {
console.log(textStatus);
});
}
Where is the problem if in postman works but from JavaScript it doesn't?
alert(user.registerDate)right after you've retrieved its value?