I have a frontend form in my custom module. On submitting the form,I want to display the success message in a popup with some custom content. How is it possible? Please help.

This is my controller.

public function formAction()
    if ($this->getRequest()->getPost()){
    //My Action
    // Mage::getSingleton('core/session')->addSuccess('Your Request has been sent');

This is my phtml

<form id="test_sample_form" method="post" action="<?php echo $this->getUrl('module/controller/action') ?>">
    <fieldset class="group-select">Test Fields</fieldset>

I want to display the success message in a popup. Please help.

  • 1
    write add success message and call in popup block Commented Jul 3, 2017 at 10:01
  • Sorry. I didn't understood. Could you please explain.
    – Vindhuja
    Commented Jul 3, 2017 at 10:02
  • i will provide code Commented Jul 3, 2017 at 10:21
  • @Rama Chandran Is there any upadate?
    – Vindhuja
    Commented Jul 3, 2017 at 11:25
  • I am checking code.not success Commented Jul 3, 2017 at 11:28

3 Answers 3


Submit the form via ajax

Use this script in your phtml:

<script type="text/javascript">
function callAjax(){ 
        type    : "POST",
        url     : "<?php echo Mage::getUrl('module/ctrlr/action'); ?>",
        data    : jQuery('#test_sample_form').serialize(),
        dataType: "json",
        complete: function (data) {
function callpopup(){ 


Submit the form via ajax

        type: frm.attr('method'),
        url: frm.attr('action'),
        data: frm.serialize(),
        success: function (data) {
            // decode JSON data and load message in popup
        error: function (data) {
            console.log('An error occurred.');

On the controller side return the value in JSON format, something like below

echo  '{"status":"true","message":"YOUR MESSAGE"}';
  • I have changed the form submission using ajax. But how is it possible to display the popup on ajax success.This is my script. complete: function(response) { alert("success"); jQuery.fancybox({ maxWidth : 450, maxHeight : 350, fitToView : false, width : '70%', height : '70%', autoSize : false, }); }, alert("success") is working. But popup is not loading. Please help.
    – Vindhuja
    Commented Jul 4, 2017 at 8:40
  • You need to trigger fancybox , check this stackoverflow.com/questions/13452197/jquery-fancybox-trigger Commented Jul 4, 2017 at 9:33

like this you can delete everything in popup and then show success content in the same popup

 if ($(this).validation('isValid')) {
                    url: $(this).attr('action'),
                    data: $(this).serialize(),
                    dataType: 'html',
                    type: 'POST',
                    showLoader: true,

                     * Success function
                    success: function () {

I take successContent from admin page so for me its like

contentOptions = {
                success: this.options.successContent

I am using popup widget.

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.