views:

256

answers:

1

I have a simple ajaxLink to a controller. It works without the params, but when I add a param I get an error: Warning: Missing argument 1 for Ez_ContactsController::testyAction()

The params are required and I see them in the jquery that ZF creates. here is the JS that gets generated (/ez is my module): $(document).ready(function() { $('a.ajaxLink1').click(function() { $.post('/ez/contacts/testy', {"param1":"1","param2":"456"}, function(data, textStatus) { $('#testy').html(data); }, 'html');return false; }); });

Here is my ajaxLink:

ajaxLink("Example 2", "/ez/contacts/testy", array('update' => '#testy', 'class' => 'someLink'), array('param1' => '1', 'param2' => '456')); ?>

Thanks for any help

A: 

I found the answer. You don't send the vars directly to the function, they are sent via GET or POST.

Here is how I got the vars. $param1 = (int)$this->_request->getParam('param1'); $param2 = (int)$this->_request->getParam('param2');

Here is the entire function: public function testyAction(){

//The request was made with JS XmlHttpRequest
$this->_helper->viewRenderer->setNoRender(); //Will not render view
    $this->_helper->Layout->disableLayout(); // Will not load the layout
$param1 = (int)$this->_request->getParam('param1');
$param2 = (int)$this->_request->getParam('param2');

    echo 'testy 123. params sent were: '.$param1.', '.$param2;

}

EricP