I have an ajax post to which I am getting values from sql database. My datatype in sql is datetime what it returns is:
Orderdate: "/Date(-62135578800000)/"
Now using date.js I am trying to do the following:
orderdate = Date.parse(response.d[post].Orderdate);
orderdate.toString('MM/dd/yyyy')
but that keeps coming up with this error:
Uncaught TypeError: Cannot call method 'toString' of null
what am i doing wrong? i don't get it :(
EDIT: here's my complete code,
$.ajax({
type: "POST",
url: "../ajaxcalls.asmx/Test",
data: "{id:'" + id + "'}",
contentType: "application/json",
dataType: "json",
success: function (response) {
for (var post in response.d) {
orderdate = Date.parse(response.d[post].Orderdate);
console.log(orderdate);
console.log(response.d[post].Orderdate);
console.log(orderdate.toString('MM/dd/yyyy'));
}
}
});
Invalid Datefor(;;;)loop instead offor(..in..)