jquery - Download file from different origin using POST request -
i'm trying prompt download request service different ui service (different domain).
trying using
$.post(url, {param1: 'param1val', param2: 'param2val'}) the server returns csv file headers i receive response csv text , not sure how (if can) make being saved file.
clarification might help:
response server
future(ok.chunked(rowenumerator.andthen(enumerator.eof)) .withheaders(("content-description", "file transfer"), ("content-transfer-encoding", "binary"), ("access-control-allow-origin","*")) .as("text/csv").withheaders(content_disposition -> s"attachment; filename=resp.csv", content_type->"application/x-download"))
it seems problem $.post using ajax , looks impossible download file way.
solution dynamically creating form element on document body attributes correspond the data attempting send in $.post.
var form = document.createelement("form"); form.setattribute(...); // method, action // each data element post request var field = document.createelement("input"); field.setattribute(...); // type(hidden), key, value form.appendchild(field); document.body.appendchild(form) form.submit()
Comments
Post a Comment