歷史上的今天json介面 ,分享給大家,資料來自wiki
$.getJSON('http://history.sturgeon.mopaas.com/jsonp?callback=?',function(data){
parserTodayObj(data);
});
functionTodayObj(data);
});
function parserTodayObj(todayObj){
for(var key in todayObj){
if(/^.*出生.*$/.test(key)){
doBirthday(today; > }
if(/^.*假期.*$/.test(key)){
doHoliday(todayObj[key]);
}
if(/^.*風俗.* $/.test(key)){
doHoliday(todayObj[key]);
}
if(/^.*逝世.*$/.test(key)){
todayObj[key]);
}
if(/^.*事記.*$/.test(key)){
doMemorabilia(todayObj[key]);
doMemorabilia(todayObj[key]);
}
parserTodayObj(todayObj);
function doBirthday(birthdays){
$(document.body).append("
" birthdayitem "
");}
}
function doHoliday(holidays){
if(holidays.length != 0){
$(document.body).append("
" item "
"); };
}
function doDeath(deaths){
if(deaths.length != 0){
$(document.body).append("
" item "
"); };
}
function doMemorabilia(memorabilias){
if(memorabilias.length != 0){
$(document.body).append("
" item "
");}
複製程式碼 程式碼如下:$.getJSON('http://history.sturgeon.mopaas.com/jsonp?callback=?',function(data){
parserTodayObj(data);
});
functionTodayObj(data);
});
function parserTodayObj(todayObj){
for(var key in todayObj){
if(/^.*出生.*$/.test(key)){
doBirthday(today; > }
if(/^.*假期.*$/.test(key)){
doHoliday(todayObj[key]);
}
if(/^.*風俗.* $/.test(key)){
doHoliday(todayObj[key]);
}
if(/^.*逝世.*$/.test(key)){
todayObj[key]);
}
if(/^.*事記.*$/.test(key)){
doMemorabilia(todayObj[key]);
doMemorabilia(todayObj[key]);
}
parserTodayObj(todayObj);
function doBirthday(birthdays){
$(document.body).append("
" birthdayitem "
");}
}
function doHoliday(holidays){
if(holidays.length != 0){
$(document.body).append("
" item "
"); };
}
function doDeath(deaths){
if(deaths.length != 0){
$(document.body).append("
" item "
"); };
}
function doMemorabilia(memorabilias){
if(memorabilias.length != 0){
$(document.body).append("
" item "
");