jQuery.ajax({
url: \"https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Confirmed
You have to use dataType
as text
and then run split
with double for loop to get the data as an array of JS objects:
jQuery.ajax({
url: "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Confirmed.csv",
type: 'get',
dataType: 'text',
success: function(data) {
let lines = data.split('\n');
let fields = lines[0].split(',');
let output = [];
for(let i = 1; i < lines.length; i++){
let current = lines[i].split(',');
let doc = {};
for(let j = 0; j < fields.length; j++){
doc[fields[j]] = current[j];
}
output.push(doc);
}
console.log(output);
},
error: function(jqXHR, textStatus, errorThrow){
console.log(textStatus);
}
});