A
A
agoge2015-08-14 16:33:27
JavaScript
agoge, 2015-08-14 16:33:27

Get pdf file with POST request via jquery.ajax()?

Actually, how can you get a pdf file from the server through a post request using $.ajax()?
I'm trying to make a request like this:

$.ajax({
type: 'POST',
dataType: '???', // какой нужно вставить правильный dataType?
url: url,
data: formData,
success: function (data) {
console.log(data);
},
error: function (data) {
console.log(data);
}
});

But the response from the server gets into error, although the markup in data.responseText is similar to pdf.
Tell me, please, what am I missing, doing wrong or not doing?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Aksentiev, 2015-08-14
@Sanasol

stackoverflow.com/a/8394118
Source

E
Evgeny Kolegov, 2015-08-14
@KollegOFF

Leave those blank, it will automatically determine by MIME from the server, the main thing is that the server would correctly give MIME.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question