0

My website layout is two layers deep (~/Layer1/Layer2/index.html and data.csv)

My goal is that when a button on the HTML page is clicked, it triggers the jQuery function (that's working) that starts the download of the data.csv file.

I can't figure out how to 1) Access the data.csv file location from javascript/jQuery. and 2)Initiate a download instead of having the webpage open is as a webpage.

Thanks!

  • Technically if you open the .csv file in a new tabs it should download on its own – Nicolas Racine Jun 15 '16 at 14:50
  • Yeah I would think that too, but all it does is open a new webapge with the location /Layer1/Layer2/data.csv instead of /Layer1/Layer2/index.html. I want it to stay on the index page and just download the file. – manufan22122 Jun 15 '16 at 14:52
  • You could use an Iframe. Take a look at http://stackoverflow.com/questions/3499597/javascript-jquery-to-download-file-via-post-with-json-data/3506018#3506018 – Nicolas Racine Jun 15 '16 at 14:53
  • @NicolasRacine — That's a **deleted** answer to a question asking how to trigger a download in response to an Ajax request. There's no Ajax involved here so no need to do anything so complicated. – Quentin Jun 15 '16 at 14:56
  • Well. There's probably no Ajax involved. The question is missing anything resembling code. It isn't clear why jQuery is involved at all. – Quentin Jun 15 '16 at 14:56
  • **Solved:** It must have been something with the file path. I changed the location of the csv file to the root folder of the website. I added an iframe in JS with the file path ../../Data.csv which worked. Thanks for the help everyone. – manufan22122 Jun 22 '16 at 18:18

0 Answers0