I would like to call a controller function and after that I would like to update my view with an ajax call.

Therefore I call my controller function from an ajax script using this url:

url: "index.php?option=com_mycomponent&task=component.save"

Everything seems fine, but I cannot access my form inputs in the controller.

$jinput = JFactory::getApplication()->input;
$data = $jinput->get('jform', 'default_value', 'filter');

$data stays empty.

When I call the function from a normal Joomla button in the form, everything is fine and all values from the form are available in the controller.

I would like to call my controller function and afterward I would like to update my view with an ajax call.

  • Are you using a post method for the ajax call? – Pep Lainez May 24 '14 at 16:55

I think you may want to try it like this:

$data  = $this->input->post->get('jform', array(), 'array');

assuming you are using joomla 3, you can use jquery for this functionality:

JHtml::_('jquery.framework'); // make sure jquery is loaded
<script type="text/javascript">
jQuery( "#yourformid" ).serialize(), function(data, 
statustxt){ jQuery('#resultdiv').html=data; })

This should return the result to an element . Docs for jQuery.post() is found here http://api.jquery.com/jquery.post/. The post-functionality should add the data from your form as post-variables for joomla to read. To see all incoming post-variables in php write


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.