I have implemented a feature in which a file is downloaded on click of a button and the same file is deleted from the server after the download completes, the file can be of size 30 MBs max. Right now with the kind of data we have, the sizes are in order of 5 MBs(but it is expected to grow).
The problem is that sometimes when I click on the button it shows a 404 maybe because the second function(the delete function) is fired as soon as the first function is fired(the download function).
The Code:
window.location = TDN.Variables.BaseURL + 'uploads/js/jsfiles.zip'; //downloads the file
jQuery.post(TDN.Variables.BaseURL + "includes/pages/recursiveRmdir/js", null, null); // deletes the file
One Possible solution is:
window.location = TDN.Variables.BaseURL + 'uploads/js/jsfiles.zip';
setTimeout(function(){ jQuery.post(TDN.Variables.BaseURL + "includes/pages/recursiveRmdir/js", null, null); }, 30000);
How can I rectify this issue? Or atleast tell me what's going on?