I have a comma separated variable in my .js file, for example:
var out=\'\'; out+=\"1,val1,val2,val3,val4\\n\"; out+=\"2,val1,val2,val3,val4\\n\"; out+=\"3,v
there is jquery plugin for output file at the client side without server side interaction,
https://github.com/dcneiner/Downloadify