Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/184.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Phonegap应用程序don';不显示下一页_Android_Jquery_Json_Wordpress_Cordova - Fatal编程技术网

Android Phonegap应用程序don';不显示下一页

Android Phonegap应用程序don';不显示下一页,android,jquery,json,wordpress,cordova,Android,Jquery,Json,Wordpress,Cordova,我试图用phonegap、jquerymobile和JSON(来自WordPressJSONAPI)构建一个应用程序。我使用下面的代码,它显示最近的文章列表(index.html) var wpAPI=”http://myurl.nl/api/get_recent_posts/"; $(文档).on('pagebeforeshow','#index',函数(){ $.getJSON(wpAPI,函数(结果){ $.each(result.posts,函数(i,项){ var html='';

我试图用phonegap、jquerymobile和JSON(来自WordPressJSONAPI)构建一个应用程序。我使用下面的代码,它显示最近的文章列表(index.html)


var wpAPI=”http://myurl.nl/api/get_recent_posts/";
$(文档).on('pagebeforeshow','#index',函数(){
$.getJSON(wpAPI,函数(结果){
$.each(result.posts,函数(i,项){
var html='
  • '; $(“.container>ul”).append(html); }); $(“#列表”).listview(“刷新”); }); });
    问题是当我试图打开其中一个帖子(post.html)时,当我导出android应用程序时,post.html不会显示任何内容

    所以我认为这是一件让人耳目一新的事情,但也许还有别的事情希望能对我有所帮助

            <script>            
    
            function readSinglePost (url,container){
    
                var postId = window.location.search;
                var URL =  'http://myurl.nl/api/get_post/'+ postId + '';
    
                jQuery.ajax({
                        url: URL, 
                        dataType: 'json', 
                        success: function(data) {
                            console.log(data);
    
                            $('.container').html("<h3>" + data.post.title + "</h3>" + data.post.content + "");
                        }
                });
    
            }
    
    
    
            $(document).ready(function(){
                readSinglePost (URL,'.container');
    
            });     
    
    
    
         </script>
    
    
    函数readSinglePost(url、容器){
    var postId=window.location.search;
    var URL='1〕http://myurl.nl/api/get_post/“+posted+”;
    jQuery.ajax({
    url:url,
    数据类型:“json”,
    成功:功能(数据){
    控制台日志(数据);
    $('.container').html(“+data.post.title+”“+data.post.content+”);
    }
    });
    }
    $(文档).ready(函数(){
    readSinglePost(URL,.container');
    });     
    
    更换
    具有
    函数readSinglePost(url、容器){
    var postId=window.location.search;
    var URL='1〕http://myurl.nl/api/get_post/“+posted;
    jQuery.ajax({
    键入:“获取”,
    url:url,
    数据类型:“json”,
    成功:功能(数据){
    控制台日志(数据);
    $('.container').html(“+data.post.title+”+data.post.content);
    }
    });
    返回false;
    }
    
    这其中的一部分就是问题所在。它可以从索引到类别,但不能从category.html到post.html。我认为必须在浏览器中重新加载某些内容(在readSinglePost函数中),它可以工作,但不能在通过href传递链接的每个锚定标记中的appAdd data ajax=“false”属性中。检查这个url“postId+”,奇怪的是我在coda中构建了它,它在那里工作,但是当我用build.phonegap.com导出它并安装到我的设备上时,它就不工作了。“取消列表”视图(index.html)起作用,指向所有类别的链接也起作用,但仅显示一篇文章“不起作用”:(我将添加完整的html代码,并在新问题找到解决方案时发布!问题是在index.html和category.html上我使用了getJson,在post.html上我使用了jQuery.ajax,我认为现在我只使用getJson失败了,这很有效!
            <script>            
    
            function readSinglePost (url,container){
    
                var postId = window.location.search;
                var URL =  'http://myurl.nl/api/get_post/'+ postId + '';
    
                jQuery.ajax({
                        url: URL, 
                        dataType: 'json', 
                        success: function(data) {
                            console.log(data);
    
                            $('.container').html("<h3>" + data.post.title + "</h3>" + data.post.content + "");
                        }
                });
    
            }
    
    
    
            $(document).ready(function(){
                readSinglePost (URL,'.container');
    
            });     
    
    
    
         </script>
    
    Replace 
    <a href="post.html?post_id='+ item.id +'"> 
    with 
    <a href="post.html?post_id='+ item.id +'" data-ajax="false" data-role="none">
    
     function readSinglePost (url,container){
    
                var postId = window.location.search;
                var URL =  'http://myurl.nl/api/get_post/'+postId;
                jQuery.ajax({
                        type: "GET",
                        url: URL,
                        dataType: "json", 
                        success: function(data) {
                            console.log(data);
                            $('.container').html("<h3>" + data.post.title + "</h3>" + data.post.content);
                        }
                });
                return false;
    
           }