jQuery Ajax Sample - 外部RSSなどからデータを得る

STUDIO KEYのWordPressブログデータを得る

jQuery

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$(function() {
  $.ajax({
    url: "proxy.php",
    dataType: "xml"
    }).done(function(xml){
      $("#blog").html(''); //ローダーを消す
      $(xml).find("item").each(function(){
        var title = $(this).find("title").text();
        $('#blog').append(title+'<br>');
      });
    }).fail(function(xml){
      $("#blog").html('取得に失敗しました');
    });
});

proxy.php

1
echo file_get_contents('http://studio-key.com/feed');