I am using Magento version.

I need form values in the controller which is other than form action. So I serialized the form values and set into the Magento Core session like below. When I print the Session Value it is returns empty or the variable name as value.

var samples = JSON.stringify(jQuery('#sell-add-product').serializeArray());
var a = "<?php echo Mage::getSingleton('core/session')->setMyValue("+samples+");?>";

I am getting like below in the controller:

 $data = Mage::getSingleton('core/session')->getMyValue();

Out put is +samples+

  • 2
    We cannot assign Javascript variable value to php. You need to set session where form posted. Means you need to assign/set form values in post action. – Nits Jan 10 '18 at 13:29
  • 1
    you can do this things using Ajax request. – Dhiren Vasoya Jan 10 '18 at 13:29

Your Answer

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

Browse other questions tagged or ask your own question.