Welcome Guest, Not a member yet? Register   Sign In
Ajax works on localhost, but not in remote!
#1

[eluser]g2r[/eluser]
I've this problem whit my ajax script.

In localhost all works fine, I can send the post data and receive the response from the controller, but when I've transferred all in my remote server It don't work.

I've tried with changing the $config['uri_protocol'], but nothing!

I don't know why It happens.

When I check with alert, on ajax callback function I get only an empty window.

It's strange...

any ideas?
#2

[eluser]Satlavida[/eluser]
Can you add the script please?
#3

[eluser]g2r[/eluser]
Yes..

This is my [removed]

Code:
$('#nextBtn a').click(function(){  
                     var num = $('#gallery_slider img').attr("alt");            
                         $('#gallery_slider img').fadeOut('slow');
                       $("#gallery_slider li").remove();
                         $.post('<?=site_url('/home/nextImg') ?>',{next:num},function (data){  
                       $("#gallery_slider ul").append("<li><img alt='"+ data.alter +"' src='"+ data.path + "' /><li>").show('slow');
                     },"json");  
                })  ;   // end next


and in the controller:

Code:
function nextImg(){    
                        
                        $next=$this->post('next');
                        $this->load->model('MGallery');
                            $res = $this->MGallery->scaNext($next);
                        echo $res;  
    }


I've tried with firebug and I can see that the post value is sent, but I can't get any response from controller.
I've also used to encode in json the return values, but nothing.
#4

[eluser]Satlavida[/eluser]
Try using base_url()
#5

[eluser]g2r[/eluser]
[quote author="Satlavida" date="1297370803"]Try using base_url()[/quote]


Thanks...but don't works.
I'm sure that the javascript invokes the controller, but nothing comes back.

I'm very confused!
#6

[eluser]g2r[/eluser]
I solved it!

I should use the exit() to return the response.

The solution was here...
http://ellislab.com/forums/viewthread/135490/#668459

Thanks




Theme © iAndrew 2016 - Forum software by © MyBB