Created
January 9, 2014 06:11
-
-
Save fddcddhdd/8330106 to your computer and use it in GitHub Desktop.
Google Ajax Feed APIを使わないでRSSを取得してみた(jQuery)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"> </script> | |
<script> | |
$.getJSON( | |
"http://localhost/rss/rss.php?callback=?", | |
{ rss_num : 5 }, | |
function(json) { | |
alert('b'); | |
//出力先要素(ID指定)を変数に格納 | |
var container = document.getElementById("feed"); | |
var htmlstr = ""; | |
//フィードの分だけループ | |
for (var i = 0; i < json.length; i++) { | |
//日付を表示 | |
htmlstr += '' + json[i]['date'] + '<br>'; | |
//タイトルとリンクを表示 | |
htmlstr += '<b><a href="' + json[i]['link'] + '" target="_blank">' + json[i]['desc'] + '</a></b><br><br>'; | |
} | |
// 要素に出力 | |
container.innerHTML = htmlstr; | |
} | |
); | |
</script> | |
</head> | |
<body> | |
<div id="feed"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment