简体   繁体   中英

How can we download the dynamically generate file from server?

I want download the file from server (I knew that we can't use AJAX, and serve is Servlet) and which dynamically generate according to the parameters.

Now I have the parameters in format JSON, like:

{"limitTo":"name","searchFor":["AAA","BBB","CCC"],...}

So, how can we send the request to the server with those paraleters? Do we need create some input s?

Thanks, I found the solution which uses dojo/request/iframe , without window.open

And the code likes :

require(["dojo/request/iframe"], function(iframe){
  // cancel the last request
  iframe._currentDfd = null;
  iframe("something.xml", {
    handleAs: "xml",
    data : "your json"
  }).then(function(xmldoc){
    // Do something with the XML document
  }, function(err){
    // Handle the error condition
  });
  // Progress events are not supported using the iframe provider
});

And then we can see download window.

Here is an article about dojo/request/iframe

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM