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();
   }
});
1

1 Answer 1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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