Unable to download large data using javascript

后端 未结 1 1222
天涯浪人
天涯浪人 2021-02-03 11:06

I have a large data in form of JSON object in the javascript. I have converted it into the string using JSON.stringify(). Now my use case is to provide this large string in a te

相关标签:
1条回答
  • 2021-02-03 11:16

    From the OP:

    I solved it as below.

    var _generateFeed = function(text) {
        /*some code here*/
        var url = URL.createObjectURL( new Blob( [text], {type:'text/plain'} ) );
        $("#textLink").attr("href",url)[0].click();
    }; 
    

    Notes:

    • URL.createObjectURL() is compatible with modern browsers and IE10+, but it is an unstable, experimental technology.
    • Objects created using URL.createObjectURL() "must be released by calling URL.revokeObjectURL() when you no longer need them." - MDN
    0 讨论(0)
提交回复
热议问题