I'm trying to automatically save a form when leaving a page with JavaScript by using the following code
$(window).unload( function() {
$("#registration-patient-form").submit();
});
Yet, somehow the form does not get submitted and I'm simply redirected to the page I'm navigating to. Any idea on how to accomplish this?