Answer the question
In order to leave comments, you need to log in
Why is pdf not downloading correctly in firefox?
Through ajax, a pdf is downloaded using the following code
jQuery('#lp-download-pdf')
.attr('href', string.trim())
.attr('download', string.split('/').pop())[0]
.click();
Answer the question
In order to leave comments, you need to log in
The above code is not directly related to the ajax technology. It just substitutes the href properties (by the presence of this property, you can guess that this is a link element) and download properties into the element with the lp-download-pdf id, then, forcibly, programmatically fires a click event, as if the user clicked on the element.
How the browser will react to a double "robotic" click on a link with the same href can only be guessed at. You can try to make the link unique on each click.
Substitute some random parameter to the link at this stage:
.attr('href', string.trim() + "?random_param=" + Math.round(Math.random() * 1000))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question