Looking to access my JavaScript file generated by a microservice (byte[]):
public int retrieveLabel(Request request, Response response) throws IOException {
response.header("Access-Control-Allow-Origin", "*");
ArrayList<JSONObject> orders = generateJSONList(request.queryParams("orders"));
response.header("Content-Type", "application/pdf");
ServletOutputStream outputStream = response.raw().getOutputStream();
outputStream.write(generatePDF(orders));
outputStream.flush();
outputStream.close();
return 200;
}
Want to receive the response via ajax:
$("#printlabels").click(function() {
var jsonData = $(this).data().ordersJson;
console.log(jsonData)
$.ajax({
// type: GET,
async: true,
url: "http://localhost:60000/api/create-label",
data: {orders: jsonData},
success: function(resp){
???;
}
});
});
Desiring for the browser to either open or save the PDF file