Tuesday, 1 October 2013

How do I correctly download a CSV with my own data?

How do I correctly download a CSV with my own data?

I have a little plugin I'm writing, which basically pulls information from
the facebook API, loops over, creates a formatted string from the data
that I want, and the forces a download once it's run, however, to my
knowledge, I'm formatting the string correctly, but I can't open the csv
(unless I'm being stupid, most likely the case...).
DEMO: http://jsfiddle.net/shannonhochkins/vUnF9/848/
However, here's a very simple example, how I'm formatting my response I'm
formatting my response:
var string = "a","b","c","d","e","f","etc";
To my knowledge, that is how the csv file expects it, yet it won't even
work when I force that information into my window.open command near the
top of the fiddle rather than pass it my custom string.
I know it's quite a big chunk of code, but I'm not sure what else I can do
here?
Even if I run :window.open("data:text/csv;charset=utf-8," +
escape("a","b","c","d","e","f","etc")) directly, the csv downloads
properly and opens, but there's no data..
Any help would be great!

No comments:

Post a Comment