使用原生PhoneGap应用程序检索Wordpress帖子



我是jQuery编程的新手,我有一个简单的应用程序,从一个文字新闻网站检索帖子,并在使用Adobe PhoneGap Build构建的本地应用程序中显示它。我使用括号来编码应用程序和括号模拟器上的帖子显示很好,但问题是,当我将其转换为使用PhoneGap构建的本地应用程序时,feed不显示。下面是Ajax调用。

<script>
function getVideos() {
    $.support.cors=true;
    $.ajax({
        url: 'http://kukonje.com/SDC/api/get_posts/',
        dataType: 'jsonp',
        jsonp:  'callback',
        jsonpCallback: 'jsonCallback',
    }).done(function (data){
        
        data.posts.forEach(function (item) {
               
          var newsfeed = '';
          //newsfeed.append('<li><a href="#container" id="VideoFeeds" data-key="'+ item.id + '"></li>');
                 newsfeed += '<div data-role="collapsible" data-theme="b">';
            newsfeed += '<h3 <a href="#" onclick="place('+item.custom_fields.tender_latitude +','+ item.custom_fields.tender_longitude +');">'+ item.custom_fields.tender_no +' '+item.title +'</a> </h3>';
            
       
            newsfeed +='<p>' + item.date+ '</p>';
            newsfeed +='<p style="font-size:10pt;">' + '  ' +item.content + '</p>';
            newsfeed +='<p style="font-size:8pt;">P' + item.custom_fields.tender_price + '</p>';
            newsfeed +='<a href="#Purchase" class="ui-btn ui-corner-all" style="border:solid 1px red">Purchase</a>';
            newsfeed +='</div>';
            
            $('#listoffeeds').append(newsfeed);
            $('#listoffeeds').collapsibleset('refresh');
               
        });
        
    }).fail(function(error){
        alert("error - " + JSON.stringify(error));
    });
}
</script>

我不知道我是否应该使用json或json来检索帖子。我如何确保在我使用phonegap构建后feed/posts显示?

Thanks in advance

function loadtenders() {
  $.ajax({
    type: "GET",
    contentType: "application/javascript",
    url: "http://kukonje.com/?json=get_posts",
    dataType: "jsonp",
    success: function(data) {
      console.log("response = " + JSON.stringify(data) + " nnlength - " + data.posts.length);
      data.posts.forEach(function(item) {
        var newsfeed = '';
        newsfeed += '<div data-role="collapsible" data-theme="b">';
        newsfeed += '<h6 style="font-style:italic,font-size:8pt;"  <a href="#" onclick="place(' + item.custom_fields.tender_latitude + ',' + item.custom_fields.tender_longitude + ');"></a> <p>Tendor No: &nbsp<b>' + item.custom_fields.tender_no + ' </b></p> <p><b> ' + item.title + '</b></p></h6>';
        newsfeed += '<p> Published Date:  &nbsp' + item.date + '</p>';
        newsfeed += '<p style="font-size:10pt;">' + '  ' + item.content + '</p>';
        newsfeed += '<p style="font-size:8pt;">P' + item.custom_fields.tender_price + '</p>';
        newsfeed += '<a href="#Purchase" class="ui-btn ui-corner-all" style="background-color:#C80000 ; width: 10em;  height: 2em;">Purchase</a>';
        newsfeed += '</div>';
        $('#listoffeeds').append(newsfeed);
        $('#listoffeeds').collapsibleset('refresh');
        console.log(" Tenders loaded");
      });
    },
    error: function(data) {
      console.log("error: " + JSON.stringify(data));
    }
  });
}

$(function() {
  $("#listoffeeds").collapsibleset({
    heightStyle: "content"
  });
  $("#listoffeeds").collapsibleset({
    collapsible: true
  });
  $(window).load(function() {
    loadtenders();
  });
});
<div data-role="collapsible-set" style="font-size:8pt;" data-inset="false" id="listoffeeds" data-theme="b"></div>

最新更新