Jquery download file on callback

I have a php script that zips up a series of files after the user selects them from the list. I am currently making an ajax call to this script, and passing it a series of URLs that need to be archived. I would like this zip file to load automatically when its finished one has been archived, and it’s hard for me to figure out how to do this. What would be the best way to force download this zip file after it is complete, assuming I am transferring the zip url from my php file back to the js file?

thank

+5
source share
3 answers

You tried:

success: function(resp) {
    window.location.href = resp;
}

, .

+4
window.location=zipfilePath;

URL-, , -, zip .

+1

Just do it window.location = zipfileurl;.

The browser will know that it cannot open zip files, so download it.

0
source

All Articles