simple facebook notification in codeigniter not run...?
===

i've got this tutorial.... simple facebook notification in PHP,, just check that the data in database have been update or not..
[Tutorial Link][1]


  [1]: http://blog.codingwear.com/read25-Membuat-Script-Notifikasi-Seperti-Facebook-dengan-jQuery-dan-PHP-.drz

So, i've been download the code and i want to use it in codeigniter,, i've made controller and the model,, and i also use ajax...

This is the code..

Model

    class Notification_model extends Model {
    
    function Notification_model() {
        parent::Model();
    }
        
        
    
    function cek_pesan()
        {
            $id_instansi = $this->session->userdata('id_instansi');
            
            $SQL = "SELECT id_sm FROM view_arus_surat_internal WHERE id_tujuan='".$id_instansi."' 
                    AND status_terima1='Belum Diterima'";
            
            $Q = count($this->db->query($SQL));
            
            return $Q;
        }  
    }

Contoller

    function cekPesan()
    {
        $this->load->model('notification_model');
        
        $data['num'] = $this->notification_model->cek_pesan();
        
        $this->load->view('notification/notification',$data);
        
    }

    function lihatPesan()
    {
        $this->load->model('notification_model');
        
        $data['num'] = $this->notification_model->cek_pesan();
        
        $this->load->view('notification/lihat_pesan',$data);
        
    }

    function tesNotif()
    {
        $this->load->view('tes_notifikasi');
    }

view notification(main view)
    <script type="text/javascript">
        
        var x = 1;
    
            function cek(){
                
                $.ajax({
                    url: "<?php echo base_url();?>main/cekPesan", //call the controller that load cek pesan view
                    cache: false,
                    success: function(msg){
                        $("#notifikasi").html(msg);
                    }
                });
                var waktu = setTimeout("cek()",3000);
            }
            
            $(document).ready(function(){
                cek();
                $("#pesan").click(function(){
                    $("#loading").show();
                    if(x==1){
                        $("#pesan").css("background-color","#efefef");
                        x = 0;
                    }else{
                        $("#pesan").css("background-color","#4B59a9");
                        x = 1;
                    }
                    $("#info").toggle();
                    //ajax untuk menampilkan pesan yang belum terbaca
                    $.ajax({
                        url: "<?php echo base_url();?>main/lihatPesan", //call the controller that load the lihat pesan view
                        cache: false,
                        success: function(msg){
                            $("#loading").hide();
                            $("#notifikasi").html(msg);
                        }
                    });
            
                });
                $("#content").click(function(){
                    $("#info").hide();
                    $("#pesan").css("background-color","#4B59a9");
                    x = 1;
                });
            });
    
        </script>

view cek pesan
     

     if($num > 0){
            echo $num;
        }

 
view lihat pesan
    
        if($num>3){
            
            echo $num;
        
        }else{
            
            die ("<font color=red size=1>Tidak ada pesan baru yang belum dibaca</font>");
    
        }

When i run it,, the notification can't show,, althought i have update the database.. Thank you...




