Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

ajax download file

$('#GetFile').on('click', function () {
    $.ajax({
        url: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/172905/test.pdf',
        method: 'GET',
        xhrFields: {
            responseType: 'blob'
        },
        success: function (data) {
            var a = document.createElement('a');
            var url = window.URL.createObjectURL(data);
            a.href = url;
            a.download = 'myfile.pdf';
            document.body.append(a);
            a.click();
            a.remove();
            window.URL.revokeObjectURL(url);
        }
    });
});
Comment

jquery ajax download file

it's called jquery migrate
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery scroll to top of div 
Javascript :: javascript Convert an array of strings to numbers 
Javascript :: track window size js 
Javascript :: js change root css variable 
Javascript :: play an audio at a specific volume in javascript 
Javascript :: how to refresh page on click of button 
Javascript :: expo build android 
Javascript :: discord.js v13 finish music play 
Javascript :: set autofocus javascript 
Javascript :: join array enclosing each value with quotes 
Javascript :: setinterval nodejs 
Javascript :: check if element is hidden jquery 
Javascript :: jquery empty ul 
Javascript :: datatables cdn file 
Javascript :: random boolean javascript 
Javascript :: “javascript factorial” Code Answer’s' 
Javascript :: nesting for loops 
Javascript :: byte to gb javascript 
Javascript :: how to check nan in jquery 
Javascript :: nestjs create controller with cmd 
Javascript :: autherization token in axios 
Javascript :: how to display uploaded image in html using javascript 
Javascript :: javascript set html value div 
Javascript :: javascript regex number only 
Javascript :: if radio checked jquery 
Javascript :: how to get current year in nodejs 
Javascript :: node list files in directory 
Javascript :: Clone an array using the JavaScript slice() method 
Javascript :: coldfusion user defined function 
Javascript :: javascript get if IE11 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =