arrayBuffer AngularJs POST request
<p>I've got a POST request like this:</p>

<pre><code> $scope.myFunction = function (name, id, value) {
      $http.post(/retrievePDFFiles, {
                    name: name,
                    id: id,
                    value: value
                }).success(function(data, headers) {
                    var filename = headers('filename');
                    if(data.byteLength &gt; 250) {
                        var blob = new Blob([data], {type : 'application/pdf;charset=utf-8'});
                        saveAs(blob, filename);
                    } else {
                        console.log("Error");
                    }

                }).error(function(data) {
                   console.log(data);
                });
}
</code></pre>

<p>With this call i send some parameters to save them in a table in my db and as response i have a pdf stream. The request to the server it returns correctly 200 and all parameters are corrected and everything is saved in db but the pdf not works. I've got an error in console:</p>

<pre><code>SyntaxError: Unexpected token %
</code></pre>

<p>and if i debug the request it goes in the .error function. I think the problem is that it doesn't recognize that it needs to download a stream and, i don't know, it doesn't work. I think just adding </p>

<pre><code>responseType : 'arraybuffer'
</code></pre>

<p>somewhere it will works but i don't know where! I can't touch the structure of the parameters.. Any idea?</p>

<p>EDIT: i tried as written here with no results
<a href="https://stackoverflow.com/questions/16791295/how-to-read-binary-data-in-angularjs-in-an-arraybuffer">How to read binary data in AngularJS in an ArrayBuffer?</a></p>