jQuery(document).ready(function(jQuery) {
  jQuery(".rss_ranking").hide();
  //alert("完了");
  $(".rss_ranking").each(function  (i) {
  var cat = jQuery(this).attr("id");
  var id = '#' + jQuery(this).attr("id");
  var loading_id = '#' + jQuery(this).attr("id") + '_loading';
  jQuery.ajax({
    url: "/api/getRssRanking", 
    success: function(html){
      //alert("XMLファイルの読み込み成功");
      jQuery(id).append(html).show(200);
    },
    error: function(){
      //alert("XMLファイルの読み込みに失敗");
      jQuery(id).append('読み込みに失敗しました。');
      jQuery(id).show();
    },
    complete:function(){
      $(loading_id).hide();
    },
    timeout:5000,
    cache: false,
    dataType: "html",
    type: "GET",
    data: "category=" + cat
  });
  
  });
  
  jQuery(".delButton").click(function(){
    var id = $(this).parents('.itemlistbox:first').attr("id");
    var cd = id.substring(6);
    var loading_id = '#loading_' + cd;
    //alert(id);
    jQuery(this).hide();
    jQuery(loading_id).show();
    
    jQuery.ajax({
      url: "/cart/delete", 
      success: function(html){
        //alert("XMLファイルの読み込み成功");
        jQuery('#' + id).remove();
        jQuery('#price_all').empty().append(html);
      },
      error: function(){
        //alert("XMLファイルの読み込みに失敗");
        jQuery(this).append('通信に失敗しました。');
        jQuery(loading_id).hide();
      },
      complete:function(){
        //$(id).hide();
      },
      timeout:5000,
      cache: false,
      dataType: "html",
      type: "GET",
      data: "cd=" + cd
    });
    
    return false;
  });

});

