1

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???

  • You can use AJAX for this. – anonymous Apr 27 '19 at 4:50
  • how??????????.. – prabhakaran7 Apr 27 '19 at 4:51
  • On click get parameters you require and post those to controller. – anonymous Apr 27 '19 at 4:57
  • here i don't want to redirect the page..... but i want i like add to cart button – prabhakaran7 Apr 27 '19 at 4:59
1

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>
|improve this answer|||||
  • Vendor/Extension/Action in here what i can give – prabhakaran7 Apr 29 '19 at 4:29
  • That is the action url of your controller. – Dhiren Vasoya Apr 29 '19 at 4:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.