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?

1 Answer 1

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. Commented Oct 3, 2016 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? Commented Oct 3, 2016 at 9:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.