I try to call my controller from a phtml template file using ajax, and I don't know what's wrong.
It looks like I got only some routing issues :
in my config.xml :
<routers>
<Samplefolder>
<use>admin</use>
<args>
<module>MyModule_Samplefolder</module>
<frontName>SampleFolder</frontName>
</args>
</Samplefolder>
</routers>
Block/Adminhtml/OnePageFolder.php:
public function getAddCardUrl() {
$url = Mage::helper('adminhtml')->getUrl('SampleFolder/OnePageFolder/AddCard');
//$url = $this->getUrl('*/*/AddCard');
return $url;
}
app/design/adminhtml/default/default/template/Samplefolder/OnePageFolder.phtml:
var url = '<?php echo $this->getAddCardUrl(); ?>';
// this url is called from http://mywebsite.com/index.php/admin/SampleFolder/OnePageFolder/index/key/cd0efd9a23e6bee7462e0fed5db6ac67/ and is looking like http://mywebsite.com/index.php/admin/SampleFolder/OnePageFolder/AddCard/key/17cf35ef0cae06459e7acf46b7e2e6d5/ which looks good
//then I call my controller with AJAX :
ajaxCall(url,5478,1234 );
function ajaxCall(url,customer_id,club_id)
{
jQuery.ajax({
url: url,
type: 'POST',
data: {customer_id:customer_id, club_id:club_id},
dataType: 'json',
success: function(json) {
if(json.response == 'ok') {
alert('good');
} else {
alert('Erreur : '+ json.message);
}
}
});
}
And Finally the controller that I can't reach
/controllers/OnePageFolderController.php:
/**
* Add club card
*
*/
public function AddCardAction()
{
var_dump('this code is not reached');
die;
}
I got the error router match 100 iteration in my ajax callback, but I don't know what is badly configured here. I use a controller already defined and working.
for example I have a non ajax button which works with a call like: Mage::helper('adminhtml')->getUrl('SampleFolder/OnePageFolder/DownloadList')
with its function just above mine in the controller.
Edit : even when I call this method directly from url, I got the error, so it means that it is not an ajax issue but a backend problem with routing behaviour