I have a magento event 'payment_method_is_active'
and I want to call event with ajax.How can I do?
UPDATE:
I have an Observer :
<frontend>
<events>
<payment_method_is_active>
<observers>
<some_observer>
<class>namespace/observer</class>
<method>checkObserver</method>
</some_observer>
</observers>
</payment_method_is_active>
</events>
</frontend>
I want that event to be dispatch everytime I click in one field.
for that I have an ajax function :
jQuery.ajax({
method: "POST",
url: "/some/url"}).done(function() {
jQuery('#fieldId').click(function(){
//Here I want to dispatch 'payment_method_is_active' event
});
});
Best Answer
You need to make ajax call to a custom controller action and do the dispatch event there as below:
In app/etc/modules/MyCompany_Ajax.xml
In app/etc/code/local/MyCompany/Ajax/etc/config.xml
In app/code/local/MyCompany/Ajax/controllers/AjaxController.php
In you template file: