I have a button and onclick it will call an ajax function.
onclick
Here is my ajax function
function csv(){ ajaxRequest = ajax();//ajax()
AJAX isn't for downloading files. Pop up a new window with the download link as its address, or do document.location = ....
document.location = ...