2

I've got a csv that I've been able to retreive using window.location = "/path/to/mydata", which I understand creates a GET request to that location. Now I'd like to add header params, so I do something like this...

$.ajax(
    url:"/path/to/mydata",
    method: "GET",
    headers: {"my-header": "..."})
.done((data){
    // "data" is now a string of my csv data
    console.log(data)
});

When I simply do window.location chrome somehow detects that I got a CSV file back and saves the contents locally to My Downloads. I'm not sure how to do that with the ajax done callback function, or if there is an ajax parameter that I could use that does it automatically.

Bharata
  • 13,509
  • 6
  • 36
  • 50
user1080952
  • 1,073
  • 2
  • 10
  • 15
  • Duplicate of https://stackoverflow.com/questions/35966526/add-header-to-window-location-pathname – Fissure King Jun 25 '18 at 17:00
  • [XY Problem](https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem). Sounds like you really want to [download a file with ajax](https://stackoverflow.com/questions/4545311/download-a-file-by-jquery-ajax) so you can set a header. – Jasen Jun 25 '18 at 18:31

0 Answers0