Convert arraybuffer to string: maximum call stack size exceeded

This is my line of code.

        var xhr = new XMLHttpRequest();
        xhr.open('GET',window.location.href, true);
        xhr.responseType = "arraybuffer";
        xhr.onload = function(event) {
         debugger;
         console.log(" coverting array buffer to string "); 
         alert(String.fromCharCode.apply(null, new Uint8Array(this.response)));
        };
        xhr.send();

This request makes for a PDF url about 3 MB in size. Read several threads with the same error, indicating that there must be some kind of recursive call, but here I don't see any recursive call. Any help?

+4
source share
1 answer

The error is caused by limiting the number of function arguments. See "RangeError: Maximum Call Stack Exceeded" Why?

String.fromCharCode.apply()Use e instead . g. a TextEncoder. See Uint8Array for string in Javascript

+7

Source: https://habr.com/ru/post/1648227/


All Articles