views:

704

answers:

1

I am trying to post some data to a controller in Kohana 3 using the jQuery AJAX method. I seem to have an issue with the data not getting to where I want it to be. I want the data to go to the /application/classes/controller/stock.php file where the file will process the data. I can't seem to figure this one out. Hopefully someone can help. My jQuery ajax call is:

        $.ajax({
            type: 'POST',
            url: 'add_stock',
            data: { 'links': 'link_array' }
            });

'add_stock' is the name of the action within the controller. I didn't know what else to try. I've also tried '.' and './' hoping that would be right but it's not. In Firebug, although it says the request was 200 OK, I see that the "RESPONSE" is "Failed to load source for: http://localhost/ddm/v2/stocks/add_stock" and my script in my controller which grabs the data isn't working. Here is that code in case it helps:

$links = $_POST['links'];

$link_obj = Jelly::factory('link')
    ->set('stock', $stock->id)
    ->set('links', $links);

    $link_obj->save();

I think that the problem is that I'm giving the ajax call the ROUTE and not the actual page it needs to deliver the POST data to. I just can't figure it out here.

Any help?

A: 

rename your controller method "add_stock" to "add_stock_action"

you can also see what exactly went wrong if you klick the link where firebug tells you 200.

antpaw