Ajax for binary data with jQuery?

I have an answer that can return text/htmlor application/octet-stream. If I get html, I would like to replace part of the page with the response data returned, and if I get binary data (file download), I would like to display a message and send the data to the browser so that the user can download the file. Is there any way to do this?

+3
source share
1 answer

The only thing I can think of is to make your loading scene two-legged. That is, first ask what type of response will be executed with the request data, and then execute the actual request and process both situations accordingly.

0

Source: https://habr.com/ru/post/1747558/


All Articles