I found some portions of codes but I don't know how to complete it. I need to pass some variables via ajax to controller in order to store them in Joomla session. So I have the code:
<input type="text" name="id" value="2" /> $('.add').click(function() { $.ajax({ method: "POST", url: "index.php?option=com_mycom&task=add&format=raw", data: {id:1}, dataType: 'json' }).done(function() { alert("Data Saved"); }); return false; }); and the code in controller:
public function add() { $session = JFactory::getSession(); $value = ??? $cart = array(); $cart['item'] = array('id' => $value); $session->set('cart', $cart); } As you see I don't know how to get data in the controller (and I'm not sure that I send it properly in $.ajax). And do I really need json in my case?