2014-03-25 49 views
0

我正在創建一個應用程序,使用sencha-touch 2和phonegap。該應用程序適用於在線報紙。我有一個jsonp文章存儲請求。 JSON請求來自使用JSON API的WordPress。當我在Web瀏覽器上查看應用程序時,文章的數量是正確的,但是當我在android手機上構建它時,無論我輸入到請求中的「count」參數是什麼,都只顯示5篇文章。Sencha phonegap JSON請求(與WordPress後端)返回只有5個項目

這是我的ArticleList.js(其包括片的靜態信息)

Ext.define('Commentator.store.Article', { 
    extend: 'Ext.data.Store', 
    requires: [ 
    'Commentator.model.Article', 
    'Ext.data.proxy.JsonP' 
    ], 
    config: { 
    storeId: 'ArticleStore', 
    autoLoad: false, 
    model: 'Commentator.model.Article', 
    proxy: { 
     timeout: 3000, 
     type: 'jsonp', 
     url: 'http://[site]/?json=get_category_posts?id=features&post_status=publish', 
     reader: { 
     type: 'json', 
     rootProperty: 'posts' 
     } 
    } 
    } 
}); 

這是我的Main.js

Ext.define('Commentator.controller.Main', { 
    extend: 'Ext.app.Controller', 

    config: { 
    refs: { 
     list: 'articles', 
     side_list: 'side_menu', 
     navBtn : 'button[name="burgerButton]', 
     topbar: 'TopBar' 
    }, 
    control: { 
     list: { 
     onDataRefresh: 'updateList', 
     tap: 'updateList' 
     }, 
     topbar: { 
     initialize: 'swipeBar' 
     } 
    } 
    }, 

    swipeBar: function(evt) { 
     evt.element.on({ 
     swipe: function(e, node, options){ 
      if (Ext.Viewport.getMenus().left._hidden) { 
      if(e.direction == "right") { 
       Ext.Viewport.showMenu("left"); 
      } 
      } else { 
      Ext.Viewport.hideMenu("left"); 
      } 
     } 
     }); 
    }, 
    updateList: function() { 
    console.log(this.getList()); 
    }, 

    //called when the Application is launched, remove if not needed 
    launch: function(app) { 
    Ext.getStore("ArticleStore").load(function(records, options, success) { 
    console.log(records); 
     if(!success) { 
     for(var i = 0; i < 5; i++) { 
      console.log("errror"); 
      Ext.getStore("ArticleStore").load(); 
     } 
     } 
    }); 
     Commentator.view.SubNavigation.setMenu(); 
    //}); 
    } 

}); 

Article.js(商店)

Ext.define('Commentator.store.Article', { 
    extend: 'Ext.data.Store', 
    requires: [ 
    'Commentator.model.Article', 
    'Ext.data.proxy.JsonP' 
    ], 
    config: { 
    storeId: 'ArticleStore', 
    autoLoad: false, 
    model: 'Commentator.model.Article', 
    proxy: { 
     timeout: 3000, 
     type: 'jsonp', 
     url: 'http://[site]/?json=get_category_posts?id=features&post_status=publish', 
     reader: { 
     type: 'json', 
     rootProperty: 'posts' 
     } 
    } 
    } 
}); 

回答

0

我找到了解決我們問題的方法。這是WordPress JSON API的問題。我們切換到Thermal API,現在它完美地工作。