SQL データベースから値を取得する ajax 投稿があります。SQL の私のデータ型は datetime です。返されるのは次のとおりです。
Orderdate: "/Date(-62135578800000)/"
現在date.jsを使用して、次のことをしようとしています:
orderdate = Date.parse(response.d[post].Orderdate);
orderdate.toString('MM/dd/yyyy')
しかし、それはこのエラーが発生し続けます:
Uncaught TypeError: Cannot call method 'toString' of null
私は何を間違っていますか?理解できません :(
編集:これが私の完全なコードです。
$.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'));
}
}
});