I'm currently in the process of developing a web application that includes a feature to trigger a backend action that may take up to 5 minutes. This backend process will run independently from the web app's front-end and back-end functionalities.
There is a form on the client side where JavaScript is used to gather, validate, and sanitize the data before sending an Ajax call to the backend to initiate the potentially lengthy process.
My main concern is what happens if a user decides to refresh the page? The backend action will still be activated and carried out, but I am aiming to receive the response once the procedure is completed so it can be displayed in the browser. Is there a way to achieve this?
The Ajax request being made is a simple POST call to my backend:
$.ajax({
type: 'POST',
url: '/add-user',
data: {'data': JSON.stringify(data)},
//contentType: 'application/json;charset=UTF-8',
success: function(response){
console.log(response['message'])
}
//timeout: 3000 // sets timeout to 3 seconds
});