jquery - Joomla 3: Serialize javascript object and save in session via Ajax -
i have script on joomla page must send javascript object this:
{ "44-00-22": "1" }
i want send via ajax controller , store in the session. ajax call looks this:
url='index.php?option=com_mycom&task=savebasket&format=raw'; var data = "request=" + json.stringify(basket); $.ajax({ type: "post", data: data , url: url, success: function(data) { squeezebox.open("index.php?option=com_basket&view=basket&tmpl=component",{ handler : 'iframe', size : { x : 600, y : 450 } }); } });
the method in controller:
public function savebasket (){ $input = jfactory::getapplication()->input; $request = $input->get('request', ''); $session = jfactory::getsession(); $session->set('request', $request); echo "saved"; }
after tried access in com_basket basket view plain string , no json string decode:
44-00-221
what correct way accomplish that? in advance.
its input type:
$request = $input->get('request', '', 'raw');
it defaults 'cmd' filters brackets. type 'raw' works expected.
Comments
Post a Comment