I have a script on a Joomla page which must send an javascript object like this:
{ "44-00-22": "1" }
I want to send this via ajax to the controller and store it in the the session. Ajax call looks like 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 the controller:
public function saveBasket (){
$input = JFactory::getApplication()->input;
$request = $input->get('request', '');
$session = JFactory::getSession();
$session->set('request', $request);
echo "saved";
}
After that I tried to access this in the com_basket basket view but it is a plain string like this and no json string that I could decode:
44-00-221
What is the correct way to accomplish that? Thanks in advance.
Its only the input type:
$request = $input->get('request', '', 'raw');
it defaults to 'cmd' which filters the brackets. With type 'raw' everything works as expected.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.