Antarmuka JSON hari ini dalam sejarah, saya akan membaginya dengan Anda.
Salinan kode adalah sebagai berikut:
//http://history.sturgeon.mopaas.com // beranda
//http://history.sturgeon.mopaas.com/jsonp?callback=?
//http://history.sturgeon.mopaas.com/jsonp // antarmuka json
//http://history.sturgeon.mopaas.com/jsonp/1@1 // 1 Januari dalam sejarah
//http://history.sturgeon.mopaas.com/1@1 // 1 Januari dalam sejarah
$ .getjson ('http://history.sturgeon.mopaas.com/jsonp?callback=?',function (data) {
parsertodayobj (data);
});
fungsi parserTodayobj (TodayObj) {
untuk (tombol var di TodayObj) {
if (/^.* lahir.*$/. Test (key)) {
Dobirthday (TodayObj [Key]);
}
if (/^.* Liburan.*$/. Test (key)) {
Doholiday (TodayObj [Key]);
}
if (/^.* khusus.*$/. Test (key)) {
Doholiday (TodayObj [Key]);
}
if (/^.* kematian.*$/. Test (key)) {
dodeath (TodayObj [Key]);
}
if (/^.* peristiwa.* $/. Test (key)) {
domemorabiliia (TodayObj [Key]);
}
}
}
Parsertodayobj (TodayObj);
fungsi dobirthday (ulang tahun) {
if (breates.length! = 0) {
$ (document.body). lampai ("<h3> lahir </h3>");
untuk (var i = 0; i <ulang tahun
var ulang tahun = ulang tahun [i];
$ (document.body) .append ("<p>"+ulang tahun+"</p>");
};
}
}
fungsi doholiday (liburan) {
if (holidays.length! = 0) {
$ (document.body) .append ("<h3> festival </h3>");
untuk (var i = 0; i <holidays.length; i ++) {
var item = holidays [i];
$ (document.body) .Append ("<p>"+item+"</p>");
};
}
}
fungsi dodeath (kematian) {
if (deaths.length! = 0) {
$ (document.body). lampai ("<h3> kematian </h3>");
untuk (var i = 0; i <deaths.length; i ++) {
var item = kematian [i];
$ (document.body) .Append ("<p>"+item+"</p>");
};
}
}
fungsi domemorabilia (memorabilia) {
if (memorabilia.length! = 0) {
$ (document.body) .append ("<h3> acara utama </h3>");
untuk (var i = 0; i <memorabilia.length; i ++) {
var item = memorabilia [i];
$ (document.body) .Append ("<p>"+item+"</p>");
};
}
}
Salinan kode adalah sebagai berikut:
//http://history.sturgeon.mopaas.com // beranda
//http://history.sturgeon.mopaas.com/jsonp?callback=?
//http://history.sturgeon.mopaas.com/jsonp // antarmuka json
//http://history.sturgeon.mopaas.com/jsonp/1@1 // 1 Januari dalam sejarah
//http://history.sturgeon.mopaas.com/1@1 // 1 Januari dalam sejarah
$ .getjson ('http://history.sturgeon.mopaas.com/jsonp?callback=?',function (data) {
parsertodayobj (data);
});
fungsi parserTodayobj (TodayObj) {
untuk (tombol var di TodayObj) {
if (/^.* lahir.*$/. Test (key)) {
Dobirthday (TodayObj [Key]);
}
if (/^.* Liburan.*$/. Test (key)) {
Doholiday (TodayObj [Key]);
}
if (/^.* khusus.*$/. Test (key)) {
Doholiday (TodayObj [Key]);
}
if (/^.* kematian.*$/. Test (key)) {
dodeath (TodayObj [Key]);
}
if (/^.* peristiwa.* $/. Test (key)) {
domemorabiliia (TodayObj [Key]);
}
}
}
Parsertodayobj (TodayObj);
fungsi dobirthday (ulang tahun) {
if (breates.length! = 0) {
$ (document.body). lampai ("<h3> lahir </h3>");
untuk (var i = 0; i <ulang tahun
var ulang tahun = ulang tahun [i];
$ (document.body) .append ("<p>"+ulang tahun+"</p>");
};
}
}
fungsi doholiday (liburan) {
if (holidays.length! = 0) {
$ (document.body) .append ("<h3> festival </h3>");
untuk (var i = 0; i <holidays.length; i ++) {
var item = holidays [i];
$ (document.body) .Append ("<p>"+item+"</p>");
};
}
}
fungsi dodeath (kematian) {
if (deaths.length! = 0) {
$ (document.body). lampai ("<h3> kematian </h3>");
untuk (var i = 0; i <deaths.length; i ++) {
var item = kematian [i];
$ (document.body) .Append ("<p>"+item+"</p>");
};
}
}
fungsi domemorabilia (memorabilia) {
if (memorabilia.length! = 0) {
$ (document.body) .append ("<h3> acara utama </h3>");
untuk (var i = 0; i <memorabilia.length; i ++) {
var item = memorabilia [i];
$ (document.body) .Append ("<p>"+item+"</p>");
};
}
}