I have the following code to fetch a PDF file and open it in a new tab:
$(document).on('click', '#downloadInvoice', function () {
    showLoader();
    $.ajax({
        type: 'POST',
        url: _baseUrl + 'orders/downloadinvoice/' + $(this).data('id'),
        xhrFields: {
            responseType: 'blob'
        },
        success: (response) => {
            const blob = new Blob([response], { type: 'application/pdf' }),
                  url  = window.URL.createObjectURL(blob)
            window.open(url);
        },
        error: () => {
            toastr.error('Error!');
        },
        complete: () => {
            hideLoader();
        }
    });
});
It works as intended in Chrome but in Firefox, it downloads the file automatically and I have to look for it in Downloads and open it manually.
Is it that Firefox prevents the opening of a new tab or do I need to add something in my code? Strangely, I have not found anything online relating to this issue.
