Welcome Guest, Not a member yet? Register   Sign In
Using AJAX to load controller?
#1

[eluser]future2012[/eluser]
Hi again Wink
Since a couple of days I were trying to process controller file through many ajax frameworks functions so it could load page in background and display response in a little pop-up - with no results.
I'd like to use it for voting system.

Schematic:
ENTRIES.php(controller+view) -> "It's good" BUTTON click -> ajax action(run "VOTES.php?action=good" in background) -> show response in popup/div (anything without refresh...)

Thanks in advance Wink
#2

[eluser]ggoforth[/eluser]
[quote author="future2012" date="1243801750"]Hi again Wink
Since a couple of days I were trying to process controller file through many ajax frameworks functions so it could load page in background and display response in a little pop-up - with no results.
I'd like to use it for voting system.

Schematic:
ENTRIES.php(controller+view) -> "It's good" BUTTON click -> ajax action(run "VOTES.php?action=good" in background) -> show response in popup/div (anything without refresh...)

Thanks in advance Wink[/quote]

I'm not quite sure if your problem lies with CodeIgniter or your ajax problems. Is votes.php part of codeigniter? If so, the get by default is unset, so if your ajax is relying on that, that may be the problem. Have you enabled the query string as part of your codeigniter config? I've never done it, but that is one thing that stands out as a potential problem.

Greg
#3

[eluser]me_not_you[/eluser]
hi,

I had the same probleme, I was using scriptaculous + prototype like so =>

Code:
[removed][removed]

[removed][removed]
[removed]
    if (!XMLHttpRequest) {
          window.XMLHttpRequest = function() {
        return new ActiveXObject('Microsoft.XMLHTTP');
          }
    }
    function startLoading() {
          Element.show('mainAreaLoading');
          Element.hide('mainAreaInternal');
    }
    function finishLoading() {
          Element.show('mainAreaInternal');
         setTimeout("Effect.toggle('mainAreaLoading');", 1000);
    }
    function loadContent(id) {
          startLoading();
          new Ajax.Updater('mainAreaInternal', '<?php echo(base_url().'index.php/manifestation/getone/'); ?>'+ id, {
            evalScripts:true,
            method: 'post',
            postBody:'content='+id,
              onComplete: function() { finishLoading();}
        });
        finishLoading();
    }
    function loaduser(id){
        startLoading();
        new Ajax.Updater('mainAreaInternal','<?php echo(base_url().'index.php/admin/getoneshow/');?>'+id, {
            evalScripts:true,
            method: 'post',
            postBody:'content='+id,
              onComplete: function() { finishLoading();}
        });
        finishLoading();
    }
    
    function loadcomparer(id){
        startLoading();
        new Ajax.Updater('mainAreaInternal','<?php echo(base_url().'index.php/manifestation/getlastyearsmanif/');?>'+id, {
            evalScripts:true,
            method: 'post',
            postBody:'content='+id,
              onComplete: function() { finishLoading();}
        });
        finishLoading();
    }
[removed]

With Firefox it works great but with IE if I call a /contoller/method => nothing

So now i'm using jquery like so

Code:
[removed][removed]

[removed]
    function get_manif(manif_id){
        showLoading();
        $('#mainAreaInternal').load('<?php echo(base_url().'index.php/manifestation/getone/'); ?>'+manif_id);
        
        hideLoading();
    }
    
    function get_user(manif_id){
        showLoading();
        $('#mainAreaInternal').load('<?php echo(base_url().'index.php/admin/getoneshow/'); ?>'+manif_id);
        
        hideLoading();
    }
    
    function showLoading(){
        //$('#mainAreaInternal').css({visibility:"hidden"})
        $('#loading').css({visibility:"visible"})
        $('#loading').css({opacity:"1"})
        $('#loading').css({display:"block"})
    }
    
    function hideLoading(){
        //$('#mainAreaInternal').css({visibility:"hidden"})
        //$('#mainAreaInternal').css({visibility:"visible"})
        $('#loading').fadeTo(1000, 0);
        
    };
[removed]

now it works great with Firefox and IE...the only thing is you cant call the javascript function again...

Hop this helps...




Theme © iAndrew 2016 - Forum software by © MyBB