1

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.

1
  • Are you using a post method for the ajax call? Commented May 24, 2014 at 16:55

2 Answers 2

1

I think you may want to try it like this:

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

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.post('index.php?option=com_mycomponent&task=component.save', jQuery( "#yourformid" ).serialize(), function(data, statustxt){ jQuery('#resultdiv').html=data; }) </script> 

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

print_r($_POST); 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.