I have my custom module and everything works fine, but I would like to create separately controller for AJAX actions (AjaxController). Currently I Have only IndexController. Everytime I get:
{"error":true,"message":"Invalid Form Key. Please refresh the page."}
Code snippets are below:
Build URL:
<script type="text/javascript">
RECALC_SP_URL = "<?=$this->htmlEscape(Mage::helper('adminhtml')->getUrl('*/productcreator_ajax/getSpecialPrice/'));?>";
</script>
**Part of config.xml*:*
<admin>
<routers>
<adminhtml>
<args>
<modules>
<productcreator after="Mage_Adminhtml">Aiti_ProductCreator_Adminhtml</productcreator>
</modules>
</args>
</adminhtml>
</routers>
</admin>
AJAX call:
jQuery( "#margin_percent" ).change(function() {
var $_this = jQuery( this );
var store_id = 0;
new Ajax.Request(RECALC_SP_URL, {
method: 'post',
parameters: {
storeId: store_id,
margin: $_this.val(),
productId: jQuery('#productcreator_product_id').val(),
},
onSuccess: function (transport) {
var response = JSON.parse(transport.responseText);
jQuery("#special_price").val(response['special_price']);
},
onFailure: function () {
}
});
});
Thank you for some help!