Welcome Guest, Not a member yet? Register   Sign In
question of ajax and CI
#4

[eluser]pistolPete[/eluser]
You need to create a function in your controller which is accessed using ajax, e.g. :

Code:
class Your_controller extends Controller {

...
    
    public function ajax()
    {
        $this->load->model(array('Datawork', 'Template', 'Form', 'Process'));
        $recordid = utf8_decode($_POST['recordid']);
        $recorddata = $this->Datawork->DBGet('records', array(id => $recordid), '', '', '');
        ...
    }
...

}

Then in the view, access the function using:

Code:
function BuyRecord(id)
{
    $('#cart').load('/your_controller/ajax', { 'recordid':[id] });
}

Have a look at some tutorials about ajax and CI:

http://www.mrforbes.com/thoughts/2009/01...-tutorial/
http://littlebrain.org/2008/05/27/codeig...-tutorial/
http://geekhut.org/2009/06/how-to-codeig...uery-json/
http://ellislab.com/forums/viewthread/71636/


Messages In This Thread
question of ajax and CI - by El Forum - 08-19-2009, 03:41 AM
question of ajax and CI - by El Forum - 08-19-2009, 04:31 AM
question of ajax and CI - by El Forum - 08-19-2009, 04:36 AM
question of ajax and CI - by El Forum - 08-19-2009, 04:49 AM
question of ajax and CI - by El Forum - 08-21-2009, 03:49 AM
question of ajax and CI - by El Forum - 08-21-2009, 04:04 AM
question of ajax and CI - by El Forum - 08-21-2009, 05:08 AM
question of ajax and CI - by El Forum - 08-21-2009, 05:38 AM
question of ajax and CI - by El Forum - 08-24-2009, 03:15 AM
question of ajax and CI - by El Forum - 08-24-2009, 03:24 AM



Theme © iAndrew 2016 - Forum software by © MyBB