Gcobani Mkontwana

Gcobani Mkontwana

  • 565
  • 1.9k
  • 406.9k

Ajax call back is not downloading my file format

Nov 11 2019 2:26 AM
Hi Team
 
I have this following code, i am using thingspeak cloud API, but if i send this request directly from the browser it seem to work and download it as CVS file. But i want my button when using Ajax call request to work the same as when requesting it to the browser to be able to download it as a CVS file.  i am following this link and seem it does not work well and dont know why,  https://nl.mathworks.com/help/thingspeak/readdata.html
 
$(document).ready(function() {
$("#download").click(function() {
$.ajax({
url:'https://www.thingspeak.com/channels/899906/feeds.csv?api_key=***&results=3',
type:'POST',
dataType:'json',
success:function(response){
window.location = response;
}
});
});
});
 

Answers (1)