Ajax copy data value to clipboard

Viewed 4517

I need to copy value of data in ajax success function

$.ajax({
    url: 'images/getDownloadUrl/',
    dataType: 'text',
    async: false,
    processData: false,
    contentType: false,
    type: 'POST',
    success: function(data){
    document.execCommand(data);
    }
});

How can i copy value of this variable data to clipboard, because this is not work if i only put execCommand?

2 Answers

With async: false, it works for me, but only once. The copy works one time, for the first click on the button which does the ajax call. Using multiple buttons also does not work - only the first click on any one button works.

Copy never works with async: true.

Related