File Download from POST submission

I apologise for the dumb question but I can't get my head around the documentation. I am trying to issue a POST submission to the server (all well and good) at which point the server performs some internal processing and then sends a (binary) file to the client. The POST submission through an ajax call is easy and the server side it straight forward.
The documentation mentions the ajax.response approach as below..

webix.ajax().response("blob").get("", function(text, data){
  //data - is a data blob

but I don't understand how this is actually implemented, or how to perform the POST and then get the browser to correctly deal with the "download headers". Is there an example of how the client (webix) side of this would tie together that I can't find? Any pointers would be very welcome.
Thanks for any and all assistance


  • edited January 2018

    webix.ajax().response("blob").get("", function(text, data){
      //data - is a data blob, "");
  • Thanks for the feedback Intregal, I was in the process of replying to you saying "yes I've read that documentation...." (which I have) when I saw the example and realised what i was missing. Thank you very much - like i said I apologise for the dumb question.

  • I'm trying this, but every single time i get a corrupt file when trying to download an image.

        var blob = new Blob([dd], {
                  type: "image/jpeg"
      , 'fuck.jpg')

    I've tried adding a delay (webix.delay())... nothing.

    Any help would be appreciated.

  • Is it possible to show a dialogue, where the user can select the dowload path, before downloading the file?

  • Hello,
    is it possible to use the filename returned by the server?

    I'm using this code:

        webix.ajax().response("blob").get("/api-v1/genforms", function(text, data) {
  , "file.docx");

    and my server returns the filename via response header:

        Cache-Control: public, max-age=0
        Content-Disposition: attachment; filename="dummy.docx"
        Content-Length: 24835
        Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document

    Browser automatically picks the filename and saves the file. Any ideas to implement the same with webix.ajax().response?

    Btw, many thanks for this great library.

    Best regards

  • edited June 22

    ajax callback receives third argument as XMLHttpRequest.
    try to get required header from this object.

    webix.ajax().response("blob").get("/api-v1/genforms", function(text, data, xhr) {
      console.log(xhr.getResponseHeader("Content-Disposition"));, "file.docx");

  • Great, this fixes my problem. Thx for the help

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!