i have a ajax call that gets me a json containing holiday dates. Now i want to convert the dates to moments and store them in an array. But my code doesn't seem to work properly. I just get empty arrays.
var holidays=[]
$.ajax({
url: 'holiday.html',
type: 'POST',
data: {
type: 'getHolidays',
start: intervalStart,
end: intervalEnd,
},
datatype: 'json',
success: function(data){
$.each(data,function(index,holiday){
holidays.push(moment.unix(holiday["date"]));
});
},
});
The Json looks like this
[
{
"date":"1545696000",
"title":"Christmas Day1"
},
{
"date":"1545782400",
"title":"Christmas Day2"
}
]