Skip to content

Instantly share code, notes, and snippets.

@fddcddhdd
Created January 9, 2014 06:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fddcddhdd/8330106 to your computer and use it in GitHub Desktop.
Save fddcddhdd/8330106 to your computer and use it in GitHub Desktop.
Google Ajax Feed APIを使わないでRSSを取得してみた(jQuery)
<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