By default, jQuery treats the response as a string. If you try to download a PDF without specifying the correct data type, the browser will likely return a corrupted file or a blank page because it tried to interpret binary data as a text string. Solution 1: Handling Binary Data (Blob)
Below is a guide on how to successfully download a PDF from an AJAX response using jQuery. The Problem with Standard AJAX download pdf from ajax response jquery
Downloading a PDF directly through an AJAX response is a common requirement for modern web applications that generate reports on the fly. However, because jQuery's standard AJAX function is primarily designed for text-based data like JSON or HTML, handling binary file streams requires specific configurations. By default, jQuery treats the response as a string
To download a PDF from a binary stream, you must set the xhrFields to expect a blob response. This allows JavaScript to treat the incoming data as a file object. The Problem with Standard AJAX Downloading a PDF