我有一個場景,我從jQuery日曆中選擇一個日期,然後通過ajax迭代JSON文件。我的問題的出現是由於使用日期範圍,例如,見STARTDATE和結束日期:JSON日期範圍從jQuery日曆
{ "campus" : "A", "periods": [
{ "startdate" : "2013-01-02",
"enddate" : "2013-01-06",
"labels" : [
{ "Wednesday":
{ "00:00" : "Closed",
"09:00" : "Open",
"18:00" : "Closed"
},
"Thursday":
{ "00:00" : "Closed",
"09:00" : "Open",
"18:00" : "Closed"
},
"Friday":
{ "00:00" : "Closed",
"09:00" : "Open",
"18:00" : "Closed"
},
"Saturday":
{ "00:00" : "Closed"
},
"Sunday":
{ "00:00" : "Closed"
}
}]
},
{ "startdate" : "2013-01-07",
"enddate" : "2013-03-24",
"labels" : [
{ "Monday":
{ "00:00" : "Closed",
"09:00" : "Open",
"18:00" : "Closed"
},
"Tuesday":
{ "00:00" : "Closed",
"09:00" : "Open",
"18:00" : "Closed"
},
"Wednesday":
{ "00:00" : "Closed",
"09:00" : "Open",
"18:00" : "Closed"
},
"Thursday":
{ "00:00" : "Closed",
"09:00" : "Open",
"18:00" : "Closed"
},
"Friday":
{ "00:00" : "Closed",
"09:00" : "Open",
"18:00" : "Closed"
},
"Saturday":
{ "00:00" : "Closed"
},
"Sunday":
{ "00:00" : "Closed"
}
}]
}
正如你可以從代碼段見上面,起始日期和結束日期是一個範圍。我想知道最好的方法是嘗試從JSON文件內的範圍內選擇一個日期。
我曾考慮使用PHP 爆炸來分解傳遞給ajax的日期,然後通過比較分解參數和startdate和enddate內的數據返回到原始頁面。我想知道是否爆炸日期,然後在startdate和enddate之間迭代以查看日期是否匹配會起作用?
如果我的上述想法不起作用,其他方式將是可能的?
歡呼聲! –