Question

I have a button in phtml file

some.phtml

<button class="example-button-1 example-button-3 :active" type="button" id="acceptnow" ><span>Active</span></button>

I want to use post method to the controller for triggering the email

but how I do that???

Was it helpful?

Solution

You can do code like this :

<script type="text/javascript">
jQuery("#acceptnow").click(function(e)
{
      var formurl = '<?php echo $this->getUrl('Vendor/Extension/Action'); ?>'; 
      jQuery.ajax({
          type: "POST",
          url: formurl,
          data:{variable:variable},
          beforeSend: function()
          {
              //do Logic before ajax request start
          }, 
          success: function(transport) 
          {
              //Do Logic when sucess comes
          },
          error: function() 
          {
              //Do Logic when error into request
          }
     });
});
</script>
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top