简体   繁体   English

使用本机 PhoneGap 应用程序检索 Wordpress 帖子

[英]Retrieving Wordpress posts using a Native PhoneGap App

I am new to jQuery programming and i have a simple app that retrieves posts from a word press site and display it in a native app built using Adobe PhoneGap Build.我是 jQuery 编程的新手,我有一个简单的应用程序,可以从 wordpress 站点检索帖子并将其显示在使用 Adob​​e PhoneGap Build 构建的本机应用程序中。 I am using Brackets to code the App and on the Brackets emulator the posts display just fine but the problem is that when i convert it to a native app using PhoneGap build the feeds do not show.我正在使用 Brackets 对应用程序进行编码,并且在 Brackets 模拟器上,帖子显示得很好,但问题是当我使用 PhoneGap 构建将其转换为本机应用程序时,提要不显示。 Here is the Ajax Call being made.这是正在进行的 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>

I do not know if I should use json or jsonp to retrieve the post.我不知道我应该使用 json 还是 jsonp 来检索帖子。 How can I ensure that the feeds/posts show after I build using phonegap?如何确保在使用 phonegap 构建后显示提要/帖子?

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) + " \\n\\nlength - " + 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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM