This jQuery helps with form submission via ajax. It will help render server side errors and takes cares of blocking the submit button to prevent the user from submitting more than once.
$.ajaxForm('#form-id').init();
The code will do the following:
- listen on form's onsubmit event
- look for url
- extract url to submit to from form's "action" attribute
- if the 'action' attribute have no url, it will use window.location.href
- serilize the form data, and submit to url via ajax
- trigger session start (lock all button, and submit input type)
- on server response, map error data to form input element, and render error
- If server does not response with error
- if server return href then redirect user to href