2

I probably know that this is something really simple, but I can not figure out what is wrong with my code. I got this

    $this->_addButton('Generate', array(
        'label'     => Mage::helper('adminhtml')->__('Generate'),
        'onclick'   =>  jQuery.ajax({url: "Mage::helper('adminhtml')->getUrl('adminhtml/generate/generate/')", 
                  method: 'GET', 
                  data: {},
                  success(function() 
                  { alert ('Generation Successful!'); }),
                  error(function() 
                  { alert ('Generation Failed!'); }),
     }),
    ), -1);

And I am getting this error: Parse error: syntax error, unexpected '{' in C:\wamp64\www\app\code\core\Mage\Adminhtml\Block\Widget\Form\Container.php on line 68

Any help please?

2

you forgot some quotes:

$this->_addButton('Generate', array(
        'label'     => Mage::helper('adminhtml')->__('Generate'),
        'onclick'   =>  "jQuery.ajax({url: '".Mage::helper('adminhtml')->getUrl('adminhtml/generate/generate/')."', 
              method: 'GET', 
              data: {},
              success(function()
              { alert ('Generation Successful!'); }),
              error(function()
              { alert ('Generation Failed!'); }),
 })",
), -1);
2
  • @DanteZ. Welcome to SE. If an answer solves your problem, mark it as accepted. – Marius Oct 3 '16 at 9:33
  • I can not mark it this early, I had to wait like 10 minutes after I posted the question. Also, is that the correct way to call another function as an event when I click on that button? – DanteZ Oct 3 '16 at 9:36

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.