I have created custom module in admin with the name createadmincontroller module and it configure the config.xml.i want to call the controller index function from .phtml with ajax but it throw an error "Uncaught TypeError: undefined is not a function" can any one tell me where I went wrong? below is my full module details:
my code is:
JR->CreateAdminController->controllers->Adminhtml->CustomController.php
<?php
class JR_CreateAdminController_Adminhtml_CustomController extends Mage_Adminhtml_Controller_Action
{
public function indexAction()
{
if(isset($_POST['data'])){
echo 'successful';
//exit;
}
$this->loadLayout()
->_setActiveMenu('mycustomtab')
->_title($this->__('Index Action'));
$this->renderLayout();
}
?>
JR->CreateAdminController->etc->config.xml
<?xml version="1.0"?>
<config>
<modules>
<JR_CreateAdminController>
<version>1.0.0</version>
</JR_CreateAdminController>
</modules>
<global>
<helpers>
<jr_createadmincontroller>
<!-- Helper definition needed by Magento -->
<class>Mage_Core_Helper</class>
</jr_createadmincontroller>
</helpers>
</global>
<admin>
<routers>
<adminhtml>
<args>
<modules>
<jr_createadmincontroller before="Mage_Adminhtml">JR_CreateAdminController_Adminhtml</jr_createadmincontroller>
</modules>
</args>
</adminhtml>
</routers>
</admin>
<adminhtml>
<layout>
<updates>
<petra>
<file>createadmincontroller.xml</file>
</petra>
</updates>
</layout>
</adminhtml>
app->design->adminhtml->default->default->layout->createadmincontroller.xml
<?xml version="1.0"?>
<layout version="0.1.0">
<adminhtml_custom_index>
<reference name="content">
<block type="adminhtml/template" name="createadmincontroller" template="createadmincontroller/index.phtml" />
</reference>
</adminhtml_custom_index>
</layout>
app->design->adminhtml->default->default->template->createadmincontroller->index.phtml
<button type="button" class="scalable" onclick="test()">Click Me!</button>
<script>
function test(){
alert("wao");
var t = '<?php echo Mage::getUrl('*/custom'); ?>';
$.ajax({
url: "<?php echo $this->getUrl('*/custom/'); ?>"
}).done(function() {
alert("Hey");
});
}
</script>
JR->CreateAdminController->Helper->Data.php
<?php
class JR_CreateAdminController_Helper_Data extends Mage_Core_Helper_Abstract
{}
?>