1. 程式人生 > >apicloud 從伺服器獲取資料 資料庫資料

apicloud 從伺服器獲取資料 資料庫資料

apicloudjs程式碼版段  通過 ajax從伺服器獲取資料

    apiready = function(){

      function getlist(){
      api.showProgress();
       api.ajax({
           url: 'http://47.92.121.206/t/index.php/index/index/getlist',
           method: 'post',
           data: {
               values: {
                   name: 'haha'
               },
               files: {
                   file: 'fs://a.gif'
               }
           }
       },function(ret, err){
         api.hideProgress();//隱藏載入進度框
           if (ret) {
             var html = '';
             for(var i=0;i<ret.length;i++)
             {
                    var cl = '<li>';
                html += cl+ret[i].subject+':'+ret[i].thumb+':'+ret[i].dt+'</li>';
             }
            //$('#listbox').append(html);
            abc = document.getElementById('listbox');
            abc.innerHTML += html;
            alert( JSON.stringify( ret ) );
          } else {
             alert( JSON.stringify( err ) );
          }
       });


      }

      getlist();


    };

thinkphp 從資料庫獲取列表資料  通過 ajaxreturn返回json資料
    //獲取二手房列表
    function getlist (){

        $data = '';
        $archives = M('archives16');
        $data = $archives
            ->alias('a')
            ->where("a.chid=3 and a.checked=1 and (a.enddate = 0 OR a.enddate > '1508306435')")
            ->join('__ARCHIVES_3__ b ON b.aid = a.aid')
            ->order('a.ccid9 desc,a.refreshdate')
            ->limit(30)
            ->select();
        //show_bug($data);
        $this->ajaxreturn($data);
    }