在我的Ionic应用程序中获取所有JSON数据时出错

时间:2017-05-04 15:06:14

标签: angularjs json ionic-framework

我试图从JSON网址获取数据到我的离子应用程序,json网址每页只显示10个帖子,帖子总数为59(计数= 59), 因此,当我想在一个页面中显示我的JSON中的所有帖子时,我使用以下URL:

http://tunisiebillet.com/api/get_posts/?post_type=product&count=59

我的问题是,当我想在我的ANGULARJS控制器上获取数据时,它不会接受超过count = 54 当我想获得超过54个帖子时,我收到此错误

ionic.bundle.js:26799 SyntaxError: Unexpected token ? in JSON at position 337731
at JSON.parse (<anonymous>)
at fromJson (ionic.bundle.js:14660)
at defaultHttpResponseTransform (ionic.bundle.js:23680)
at ionic.bundle.js:23771
at forEach (ionic.bundle.js:13696)
at transformData (ionic.bundle.js:23770)
at transformResponse (ionic.bundle.js:24559)
at processQueue (ionic.bundle.js:29132)
at ionic.bundle.js:29148
at Scope.$eval (ionic.bundle.js:30400)

这是我的控制者:

.controller('MainCtrl',function($http , $scope , $sce , $ionicScrollDelegate){

$scope.recent_posts=[];
$http.get("http://tunisiebillet.com/api/get_posts/?post_type=product&count=59").then(function(data){
    console.log(data);
    $scope.recent_posts=data.data.posts
    $scope.recent_posts.forEach(function(element,index,array){
        element.excerpt= element.excerpt.substr(0,100);
        element.excerpt= element.excerpt+"...Read More";
        element.excerpt=$sce.trustAsHtml(element.excerpt); 
    })

},function(err){

})

    $scope.loadMore=function(){

    }


    $scope.searchTextChanged=function(){
        $ionicScrollDelegate.$getByHandle('mainScroll').scrollTop(true);
    }

})

0 个答案:

没有答案