CodeIgniter Forums
can't not load controller in ajax url,, - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: can't not load controller in ajax url,, (/thread-53244.html)



can't not load controller in ajax url,, - El Forum - 07-16-2012

[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...


can't not load controller in ajax url,, - El Forum - 07-16-2012

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

What errors do you see in firebug/console?


can't not load controller in ajax url,, - El Forum - 07-16-2012

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



can't not load controller in ajax url,, - El Forum - 07-16-2012

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

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


can't not load controller in ajax url,, - El Forum - 07-16-2012

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

What errors in js console?


can't not load controller in ajax url,, - El Forum - 07-16-2012

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