Download a file and redirect it to another page via ajax

后端 未结 12 2247
盖世英雄少女心
盖世英雄少女心 2021-02-02 09:44

I have a simple contact form for download excel file . Main issue happen , When ajax load .I want to download excel file then redirect user to a next page.. Below is my code wit

12条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-02 10:22

    In Ajax....Simply you can create an excel file on server ... ajax response will be the path of the excel file...On ajax success open the excel file in new tab (it automatically downloads excel) and at the same time open new tab with new location.

    sample code inside ajax success given below

      window.open("path to excel..");
        window.open("new location");
    

    also can use (if needed)

    window.location.replace("new location");
    

    Open multiple links in Chrome at once as new tabs

提交回复
热议问题