Can I cancel a request (POST) made by a form after it has been submitted?
I transfer * a large amount of data from the database directly to the client for download (i.e. Content-Disposition: attachment;). To do this, I create a temporary form and submit it (so that I can send request parameters in the body and still have a browser loading the response as a file).
var form = document.createElement('form');
form.setAttribute('method', 'post');
form.setAttribute('action', '/query/stream');
var paramElement = document.createElement('input');
paramElement.setAttribute('type', 'hidden');
paramElement.setAttribute('name', 'jsonParams');
paramElement.setAttribute('value', JSON.stringify(reqParams));
form.appendChild(paramElement);
document.body.appendChild(form);
form.submit();
document.body.removeChild(form);
However, after downloading, it may take up to a minute to download (while the data retrieves the data). I want the user to be able to cancel the request after sending. Is it possible?
In case this is useful, the client side is AngularJS and the server side is Node.js.
* , , , .
Update
AJAX, . AJAX , ( ) load. .