Tolong pilih kategori sesuai, jenis posting (diskusi atau bukan) dan sertakan tag/topik yang sesuai seperti komputer, java, php, mysql, dll. Promosi atau posting tidak pada tempatnya akan kami hapus!
- Bagi Anda yang ingin mendaftar, baca link berikut:
http://diskusiweb.com/discussion/50491/how-to-registrasi-diskusiweb-com-baca-ini-terlebih-dahulu
- Cara menyisipkan kode program supaya tampil rapi dan terformat dengan baik di diskusiweb.com: http://www.diskusiweb.com/discussion/50415/cara-menyisipkan-kode-program-di-diskusiweb-com
- Cara posting gambar/image di post Anda: http://www.diskusiweb.com/discussion/47345/cara-menyisipkan-menyertakan-image-pada-posting/p1

infinite scroll ajax codeigniter hasilnya error

ini sebagian dari view info.php yang dikenai event mouse scroll, yang diulang table row-nya : 

                    <!--?php  $i=0;
                       foreach ($undg[$value['req']] as $row) { $i++;    
                    ?-->
                    <tr class="<?php echo ($i%2==0) ? 'undangan-basic' : 'undangan-basic-alt' ?>" id="alldata"><td>
                        <!--?php echo $row['nama'];?-->
                        </td>
                        <td>
                        <!--?php echo $row['alamat_tujuan'];?-->
                        </td>
                        <td>
                        <!--?php echo $row['tarif'];};?-->
                        </td>
                    </tr>
                    <!--?php } ?-->
                </tbody>
            </table>

ini javascript di view info.php :

<script type="text/javascript">
$(document).ready(function(){
var i = 2;
var total=" ";
$('#more').hide();
$('#no-more').hide();
$(window).on('scroll', function(e){
$this = $(this);

if($this.scrollTop() == ($(document).height() - $(window).height())){
$('#more').show();
page(i);
i++;
}

});

function page(page = 1){
if((i-1)* 2 > total){

$('#more').hide();
$('#no-more').show();
}else{
$.ajax({
'url': '',
asynch: false,
'type': 'get',
//'dataType': 'json',
'data': {
page: page
},
'success': function(response){
console.log(response);
$('#alldata').append(response);

}
});
}
}

});

</script>





ini view page.php untuk menyimpan data perulangan ajax :










ini function page() di controller pickup.php :

public function page($req_id)
{
//$this->load->library('session');
//$request_id = $this->session->excel_id;

$data = array('paging'=>array(), 'result'=>array());
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
$perpage = 10;
$limit = ($page - 1) * $perpage;

$this->load->model('excel');
$this->db->limit($perpage, $limit);
$data['result'] = $this->excel->info_limit($req_id);

$this->load->model('excel');
$data['total'] = $this->excel->info_limit($req_id);
$jml= count($data['total']);
$total_page = ceil($jml / $perpage);

$data['paging'] = array(
'page'=>$page,
'perpage'=>$perpage,
'total_page'=>$total_page
);

foreach ($data['result'] as $row) {
$req_id = $row['request_id'];
$nama = $row['nama'];
$alamat = $row['alamat_tujuan'];
$tarif = $row['tarif'];
}

$this->load->view('page',$data);

}


ini model info_limit() di excel.php :

function info_limit($req_id)
{

$this->db->select("excel_id,request_id,to_name as nama,to_address as alamat_tujuan,to_zipcode as kode_pos, ifnull(tariff,0) as tarif ");
$this->db->where('request_id =', $req_id);
$query = $this->db->get('excel');
return $query->result_array();
}

code diatas ERROR : undefined variable $req_id pada controller.. Help me, master :(
Tagged:
Sign In or Register to comment.