3

I am submitting the form by ajax. It's working properly but I have one issue with the success message.

After ajax success, I have to display success message like default Magento2. How can I achieve this?

$.ajax({
    url: "<?php echo $block->getUrl('frontname/order/save'); ?>",
    type: "POST",
    dataType: "text",
    data: "cancel= " + orderJSON,
    showLoader: true,
    success: function () {
    $("#" + id).remove();
    window.location.reload();
   }
});
Dhaduk Mitesh
  • 1,675
  • 1
  • 11
  • 29
Magecode
  • 1,504
  • 2
  • 18
  • 43
  • I had the same issue, asked and answered here: https://magento.stackexchange.com/a/237973/6549 – Holly Aug 10 '18 at 12:51

1 Answers1

0
define(['Magento_Customer/js/customer-data'], function (customerData) {
customerData.set('messages', {
    messages: [{
        text: 'message to display',
        type: 'success'
    }]
});});
Guru
  • 495
  • 1
  • 6
  • 25