• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
can't not load controller in ajax url,,

#1
[eluser]beben[/eluser]
I want to load view using ajax,, so i call the controller in ajax,, but,, nothing changed,, i can't load the controller.. this is my code...

Code:
var x = 1;

        function cek(){
            $.ajax({
                url: "<?php echo base_url();?>main/cekPesan",
                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: "<?=base_url();?>main/lihatPesan",
                    cache: false,
                    success: function(msg){
                        $("#loading").hide();
                        $("#konten-info").html(msg);
                    }
                });
        
            });
            $("#content").click(function(){
                $("#info").hide();
                $("#pesan").css("background-color","#4B59a9");
                x = 1;
            });
        });

Thank you...

#2
[eluser]CroNiX[/eluser]
Is this a standalone js file?

What errors do you see in firebug/console?

#3
[eluser]InsiteFX[/eluser]
Your missing this
Code:
type: 'POST',

#4
[eluser]beben[/eluser]
@CroNiX,, this inline js.. but.. what's the diffirent ??

@InsiteFX,, i've tried it,, nothing changes...

#5
[eluser]CroNiX[/eluser]
If it was standalone you wouldn't be able to use php in it.

What errors in js console?

#6
[eluser]InsiteFX[/eluser]
Also your using full php tags in one url and short php tags in the other url.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.