Welcome Guest, Not a member yet? Register   Sign In
Ajax $.get call and codeigniter
#1

[eluser]FabioAntunes[/eluser]
here's the deal, I have this code:
Code:
$.get(
  url, //base_url()mycontroller/ajax_get
  {some_data1: data1, some_data2: data2},
  function(responseText){
   $('#ajax').html(responseText);
  }).complete(function() {
   //do monkey business
});

and I have this in my controller
Code:
public function ajax_get(){
if($this->input->is_ajax_request()){
          if($this->input->get ( )){ //I want the ajax GET to be redirected to here
           $something['data1']=$this->input->get('data1');
           $something['data2']=$this->input->get('data2');
          }
          else

           $something= array();
          //with this javascript code I'm getting redirected to here
        
         }elseif($this->input->post ( )){
          //yada yad
          
         }
         else{
          if($this->input->get ( )){ //this one is working if I write the url correctly and press enter. So I think that's not a ROUTES.PHP problem
           $something['data1']=$this->input->get('data1');
           $something['data2']=$this->input->get('data2');
          }else
           $something= array();
          
          
          //yada yada
         }
        }
}

I think the problem is somewhere in the javascript part, I'm using Firebug and in the NET->XHR the request is something like this
GET ajax_get

usually when you do a GET call you have a tab for the parameters,

So in the firebug NET->XHR tab, I should've something like this
GET ajax_get?some_data1=etc?some_data2=etc2

Any ideas?


Messages In This Thread
Ajax $.get call and codeigniter - by El Forum - 06-10-2012, 10:23 PM
Ajax $.get call and codeigniter - by El Forum - 06-11-2012, 09:10 AM
Ajax $.get call and codeigniter - by El Forum - 06-11-2012, 12:26 PM
Ajax $.get call and codeigniter - by El Forum - 06-11-2012, 12:30 PM



Theme © iAndrew 2016 - Forum software by © MyBB