Download file from Ajax (sort of)

前端 未结 4 797
梦如初夏
梦如初夏 2021-01-03 08:11

I have this ajax call in my GSP:

$.ajax({
    url: \'${request.contextPath + \'/Ticket/passAll\'}\',
    type: \'POST\',
    data: data,
    success: functio         


        
4条回答
  •  一整个雨季
    2021-01-03 08:34

    Im a little late on this one but stumbled upon it doing some research. This solution is a bit longer and cobbled together from various questions answered here. I think its a direct answer to this question and I have it working in an application.

    
    

    The first function is a standard ajax call to get the array of data from a backend call. The next is to create the csv. The second line calls a third function that formats the csv file. The second function moves on from the csv creation and finally creates a dynamic link that is appended to the dom and clicked for the download. Seems the longer way round but works with standard ajax call to the backend.

提交回复
热议问题