I have a javascript object of the format,
obj= {name:"name", phone:"phone" , email:"email"}
I want this to be downloaded on click of a button as a CSV file.
var list = []
var saveids = function(){
obj.forEach(function(userrecord){
list.push([obj.name,obj.email,obj.phone]);
});
window.open("data:text/octet-stream;charset=utf-8," + escape(list));
}
UI Part
$('#saveids').click(function(){
saveids();
}
This opens a new window with all the data in a single continuous line.
I cant figure out how to properly format the data as CSV and how to make the <a #saveids> generate a download file link.