Welcome Guest, Not a member yet? Register   Sign In
How to pass ANYTHING to CI via jQuery's $.get() method....
#1

[eluser]stormbytes[/eluser]
This should have taken all of 5 minutes, but alas....

I'm trying to make a simple jQuery ajax call using $.get() and pass some params to the receiving CI function:

Here's the controller's method:
Code:
// Tried this first

public function test($foo)
{    
    $this->firephp->log($foo, 'GET Arr');
    
    if( ! $foo)
    {
        echo 0;
    }
    else
    {
        $stack = json_decode($foo);
    
        echo 'GET success: ' .$stack->stack_id;
    }
}


// Then I tried this...

public function test()
{
    $foo = $this->input->get('', TRUE);
    
    $this->firephp->log($foo, 'GET Arr');
    
    if( ! $foo)
    {
        echo 0;
    }
    else
    {
        $stack = json_decode($foo);
    
        echo 'GET success: ' .$stack->stack_id;
    }
}

Both times I'm getting 'FALSE' for GET. That is, no data is being received....

Here's the jQuery code:
Code:
$.get('http://sandbox/ajax/test', {'foo':'bar'}, function(data) {
        alert(data);
    });

Is there some bug or setting I'm unaware of? Mind boggling...


Messages In This Thread
How to pass ANYTHING to CI via jQuery's $.get() method.... - by El Forum - 04-21-2011, 12:23 AM



Theme © iAndrew 2016 - Forum software by © MyBB