How to download the file stream returned through the background of ajax API in JS? Ask for help

the code is as follows

var url = "{-sharp$apiHost-sharp}/aw/export?brand_ids="+brand_ids;
var settings = {
  "async": true,
  "crossDomain": true,
  "url": url,
  "method": "GET",
  "headers": {"token": "{-sharp$smarty.session.pc_token-sharp}","os": "1"}
}
$.ajax(settings).done(function (response) {
    // console.log(response);


});

where headers is the permission check, and the response returned in done is the file stream (a zip package). How to download this file stream normally in JS?

Mar.31,2021

Blob is the content of xhr 2 , but jquery is not supported. You can consider axios or native xhr/fetch .


@ it hurts to change your name

I have this way to check the information,

var url = "{-sharp$apiHost-sharp}/aw/export?brand_ids="+brand_ids;
var xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.withCredentials = true;
xhr.responseType = "blob";
xhr.setRequestHeader("token", "{-sharp$smarty.session.pc_token-sharp}");
xhr.setRequestHeader("os", "1");
xhr.send();
xhr.onload = function() {
    if (this.status == 200) {
        try{
            var elemIF = document.createElement("iframe");
            elemIF.src = this.responseURL;
            elemIF.style.display = "none";
            document.body.appendChild(elemIF);
        }catch(e){
        }
    }
}

but using this method has the following problem. I don't know how to solve

Would it be more convenient for

to return the address of this file and jump there directly?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eb2455-23be.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eb2455-23be.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?