0

I have a variable in javascript which i want to convert in txt file and then download. Please suggest.

var data = '<?xml version="1.0" encoding="utf-8"?><info><scope><vendor id="37515"><id="175090453884"/></vendor></scope><vc>YoAAQA=</vc></info>';

i have implemented below code as well but not working.

 if(!contentType) contentType = 'application/octet-stream';
    var a = document.createElement('a');
    var blob = new Blob([data ], {'type':""text/csv""});
    a.href = window.URL.createObjectURL(blob);
    a.download = "aa.txt";
    a.click(); 
Abhinav Parashar
  • 619
  • 4
  • 11
  • 27
  • Create a fiddle for the problem. – Adam Azad Jun 14 '16 at 07:15
  • "not working" is not a useful problem statement. What happens? What do you see in the web console? How have you tried to debug it? What references have you read to understand what it's doing? (Note that what you've quoted has a basic syntax error and will show that error in the console.) – T.J. Crowder Jun 14 '16 at 07:15

0 Answers0