'Why is my download failing for most recent csv file?
I am attempting to download the most recently upload csv file. The app is built with express, html, and javascript, just FYI. I have an anchor tag in my index.html file and inside of my app.js file's success callback I am attempting to download the appropriate data. However, I am coming up with Failed - No File. Below you will find my index.html and app.js relevant code:
index.html:
<a href="csv.txt" id="download" download>Download CSV</a>
app.js:
$('form').on('submit', function (event) {
event.preventDefault();
var newInfo = document.getElementById('info').files[0];
var formData = new FormData();
formData.append("jsonfile", newInfo);
$.ajax({
type: 'POST',
url: '/upload_json',
data: formData,
contentType: false,
processData: false,
success: function (data) {
console.log('DATA: ', data);
$('#csv').html(data);
$("a").attr("href", data)
},
error: function(err) {
console.log('ERR: ', err.responseText);
}
})
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
