Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Marc-AndrĂ© 63 posts 279 karma points
    Feb 20, 2020 @ 17:44
    Marc-André
    0

    Prevent page from refreshing after a form is submited

    Hello!

    In Umbraco Forms, I want to display a message instead of redirect to a confirmation page. The page still refresh and then I see my confirmation message. Sinc emy form is in a modal, I don't want my page to refresh.

    How can I achieve that?

    Thanks Umbraco community!

  • Andy Shokry 5 posts 75 karma points
    Apr 15, 2020 @ 14:58
    Andy Shokry
    0

    I would like to know the answer to this as well. Everything seems to work, except the page is refreshed when the form is submitted.

    Umbraco Forms 7.3.1

  • Yakov Lebski 594 posts 2350 karma points
    Apr 28, 2020 @ 15:34
    Yakov Lebski
    0

    you can just do ajax call instead of regular submit

    $.ajax({
        url: $form.attr('action'),
        type: 'POST',
        cache: false,
        data: $form.serialize(),
        success: function (result, textStatus, request) {
            //Show popup here
        }
    });
    
  • lori ryan 239 posts 573 karma points
    May 06, 2021 @ 19:18
    lori ryan
    0

    Yakov Would you have a more complete answer of changing the default form submission to an ajax submission?

  • Huw Reddick 1932 posts 6722 karma points MVP 2x c-trib
    May 07, 2021 @ 09:38
    Huw Reddick
    100

    Something like this should work

     $('#IDOFYOURFORM').on('submit', function (e) {
         e.preventDefault();
         var $form = $(this);
         $.ajax({
             url: $form.attr('action'),
             type: 'POST',
             cache: false,
             data: $form.serialize(),
             success: function (result) {
                //do something with result here
    
             },
             error: function (xhr, ajaxOptions, thrownError) {
                 alert(xhr.responseText);
             }
         });
     });
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies