Welcome Guest, Not a member yet? Register   Sign In
javascript calling controler without form
#4

[eluser]attos[/eluser]
You are correct. To pass a parameter to the controller you should add a 'data' element to the ajax call. The trick is that it has to be a javascript object.

Lets assume you some how get the id into a variable, called id.

Your ajax call should look like this (plan text, no code highlighting, I noticed that highlighting the code chops off the <?php and ?&gtWink:

Code:
$.ajax({
    type: "POST",
    url: "<?php echo site_url()?>/contact/feedback",
    data: {'id' : id },
    ...

Then in your controller you should be able to retrieve the id from the input object:

Code:
$id = $this->input->post('id');

and call the model with something like:

Code:
$this->model_name->some_function($id);


Messages In This Thread
javascript calling controler without form - by El Forum - 09-24-2009, 02:13 PM
javascript calling controler without form - by El Forum - 09-25-2009, 07:21 AM
javascript calling controler without form - by El Forum - 09-25-2009, 10:08 AM
javascript calling controler without form - by El Forum - 09-29-2009, 07:45 AM
javascript calling controler without form - by El Forum - 09-29-2009, 07:33 PM
javascript calling controler without form - by El Forum - 09-30-2009, 02:09 PM
javascript calling controler without form - by El Forum - 10-01-2009, 09:45 AM
javascript calling controler without form - by El Forum - 10-01-2009, 09:48 AM
javascript calling controler without form - by El Forum - 10-01-2009, 11:06 AM
javascript calling controler without form - by El Forum - 10-01-2009, 11:25 AM
javascript calling controler without form - by El Forum - 10-09-2009, 10:39 AM



Theme © iAndrew 2016 - Forum software by © MyBB