There are 2 different ways, that I've seen, to achieve this.
The full AJAX way -> If you are using JQuery (or a-n-other type of JS library with ajax/async posting abilities) you could hook into the press of the submit button, cancel the default behavour, manually serialise the form. and submit it via an AJAX call. However, there is quite alot of manual behaviours you need to consider when doing this, such as error handling, response types etc.
The other approach, and one I've used on v7 and v8 sites, is to take advantages of Unobtrusive Ajax, stuff from MVC concepts. Paul Seal has a great video/blog about it here: https://codeshare.co.uk/blog/how-to-change-a-form-in-mvc-to-submit-with-ajax/. One thing to note, in this blog, Paul uses the Ajax.BeginForm helper, but you can manually add the same data attributes to a Html.BeginUmbracoForm approach (which personally I think is better).
umbraco forms ajax submission
Hi just wondering is there any more recent solutions of getting umbraco forms to post with ajax so the page doesnt refresh and maintain page position?
Hi Lori,
There are 2 different ways, that I've seen, to achieve this.
The full AJAX way -> If you are using JQuery (or a-n-other type of JS library with ajax/async posting abilities) you could hook into the press of the submit button, cancel the default behavour, manually serialise the form. and submit it via an AJAX call. However, there is quite alot of manual behaviours you need to consider when doing this, such as error handling, response types etc.
The other approach, and one I've used on v7 and v8 sites, is to take advantages of Unobtrusive Ajax, stuff from MVC concepts. Paul Seal has a great video/blog about it here: https://codeshare.co.uk/blog/how-to-change-a-form-in-mvc-to-submit-with-ajax/. One thing to note, in this blog, Paul uses the
Ajax.BeginForm
helper, but you can manually add the same data attributes to aHtml.BeginUmbracoForm
approach (which personally I think is better).Thanks
Nik
is working on a reply...