I have this function:
public function adminhtmlWidgetContainerHtmlBefore($event)
{
$blockID = Mage::app()->getRequest()->getParam('id');
$js = "<script type='text/javascript'>
jQuery.ajax({
url: '".Mage::helper('adminhtml')->getUrl('adminhtml/index/generate/')."',
method: 'GET',
data: {FeedId : ".$blockID."}}).success(function(){
alert ('Generation Successful!');
}).error(function(){
alert ('Generation Failed!');
});
</script>";
$block = $event->getBlock();
$test= Mage::getModel('test/test')->getCollection();
if($test)
{
foreach($test as $currentFeed)
{
if($blockID == $currentFeed->getData('id'))
{
$link = $currentFeed->getData('filename');
$block->addButton('Download', array(
'label' => Mage::helper('adminhtml')->__('Download'),
'onclick' => "window.open('http://test.com".$link."', '_blank', 'Download')"
), -1);
$block->addButton('Generate', array(
'label' => Mage::helper('adminhtml')->__('Generate Feed'),
'onclick' => $js,
'class' => 'go'
), -1);
}
}
}
}
And I am getting an error when I try to click the Generate button, the error is:
(index):646 Uncaught SyntaxError: Unexpected token <
And I am not sure why, the problem is with my $js value, but it seems correct, what could actually cause this error? I know it is something simple but I can not figure it out.
Thank you.