使用mustache.js

时间:2015-08-08 19:00:37

标签: javascript jquery json mustache

有人可以帮我这个代码吗?我需要帮助。 这是我的HTML代码

<body>
  <div class="featured" onload="OnLoad_FeaturedEpisode();">
</body>

以下是我在代码中的代码:

function OnLoad_FeaturedEpisode(){
  var url="http://api.-----/---------------tPVqYBsh-tiEtWp9U-s_kIHKVs-s_m=siib-oHSD0Q2Q-oHPFq0Zu-n5sgFHyQ/format=json/canvas/get/videos";
  ProcessData(url,CallBack_FeaturedEpisode);
}

function ProcessData(SpecificUrl,Success_CallBack){
  var ReceiveResponse = "";
  var form_data = {};

  $.ajax({
     type: "POST",
     url: SpecificUrl,
     data: form_data,
     dataType: "json",
     success: function(response) {
       console.log(response);
       Success_CallBack(response);  
     }
    })                  
}

function CallBack_FeaturedEpisode(pResponse)
{
  var template= "{{#items}}
<div class="featured"><img src="{{thumbnailURL}}"><br><p>{{name}}</p></div>
    {{/items}}";
    var html=Mustache.to_html(template,pResponse.items);
    $('.featured').html(html);     
  });   
}

0 个答案:

没有答案