-3
$(function()
{
    function after_form_submitted(data)
    {
        if(data.result == 'success')
        {
            $('form#reused_form').hide();
            $('#success_message').show();
            $('#error_message').hide();
        }
        else
        {
            $('#error_message').append('<ul></ul>');

            jQuery.each(data.errors,function(key,val)
            {
                $('#error_message ul').append('<li>'+key+':'+val+'</li>');
            });
            $('#success_message').hide();
            $('#error_message').show();

            //reverse the response on the button
            $('button[type="button"]', $form).each(function()
            {
                $btn = $(this);
                label = $btn.prop('orig_label');
                if(label)
                {
                    $btn.prop('type','submit' );
                    $btn.text(label);
                    $btn.prop('orig_label','');
                }
            });

        } 
        //else
    }

    $('#reused_form').submit(function(e)
      {
        e.preventDefault();

        $form = $(this);
        //show some response on the button
        $('button[type="submit"]', $form).each(function()
        {
            $btn = $(this);
            $btn.prop('type','button' );
            $btn.prop('orig_label',$btn.text());
            $btn.text('Sending ...');
        });


                    $.ajax({
                type: "POST",
                url: 'handler.php',
                data: $form.serialize(),
                success: after_form_submitted,
                dataType: 'json'
            });

      });
}); 

Even don't work here to post it good. Don't know what to do help me out.

Jules Dupont
  • 7,259
  • 7
  • 39
  • 39

1 Answers1

0

Not sure if this is what you meant but this works:

$(function() { 

  function after_form_submitted(data) { 
    if(data.result == 'success') { 
      $('form#reused_form').hide(); 
      $('#success_message').show(); 
      $('#error_message').hide(); 
     } 
    else {  
      $('#error_message').append('');
      jQuery.each(data.errors,function(key,val){
                $('#error_message ul').append('<li>'+key+':'+val+'</li>');
            });
      $('#success_message').hide();
      $('#error_message').show();

            //reverse the response on the button
      $('button[type="button"]', $form).each(function()
                                             {
        $btn = $(this);
        label = $btn.prop('orig_label');
        if(label)
        {
          $btn.prop('type','submit' );
          $btn.text(label);
          $btn.prop('orig_label','');
        }
      });
    }
  }


  $('#reused_form').submit(function(e){
      e.preventDefault();
      $form = $(this);
      //show some response on the button
      $('button[type="submit"]', $form).each(function()
      {
          $btn = $(this);
          $btn.prop('type','button' );
          $btn.prop('orig_label',$btn.text());
          $btn.text('Sending ...');
      });
      $.ajax({
              type: "POST",
              url: 'handler.php',
              data: $form.serialize(),
              success: after_form_submitted,
              dataType: 'json'
          });
    });


});
Turo
  • 1,537
  • 2
  • 21
  • 42
  • nope i dont get the email form into my meila dont know where is my problem... i got this from this link http://reusableforms.com/d/p/bootstrap-popup-email-form and put it into the webpage am doing for myself – Salvador Reyes Apr 21 '18 at 23:59
  • your question indicates that you had a problem with formatting the code. If you have a different question, do your best to ask the question not confuse the people trying to help you. – Turo Apr 22 '18 at 00:02