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 :: how to cause a whole page reload react redux 
Javascript :: list of alphabet letter english for js 
Javascript :: generator function javascript 
Javascript :: javascript good practice 
Javascript :: sort numbers in array in js 
Javascript :: center canvas p5js 
Javascript :: target child event 
Javascript :: find all of array which satisfy condition javascript 
Javascript :: react-dropzone 
Javascript :: math random javascript 
Javascript :: javascript focus on contenteditable not working 
Javascript :: mongoose updatemany example 
Javascript :: js byte size 
Javascript :: node js require file in parent directory 
Javascript :: javascript get last word in string 
Javascript :: js promise 
Javascript :: how to count seconds in javascript 
Javascript :: how to clone an object in javascript 
Javascript :: iteratea on values map js 
Javascript :: Javascript Event Loop 
Javascript :: deno vs nodejs 
Javascript :: react redux not updating 
Javascript :: react native stylesheet shortcut 
Javascript :: enzyme testing 
Javascript :: react chartjs 
Javascript :: vanilla js http server 
Javascript :: react: fow to use find(to get the id of a element 
Javascript :: Check if instance is array 
Javascript :: dynamic forms in react 
Javascript :: copia independiente array javascript 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =