I want just one time click my code always clicks and chrome blocks
im very happy if anyone help me
$(document).ready(function(){
$('.mp3download').click(function(e){
var button = $(this);
if (button.data('id') == 3) {
if (button.data('status') == false) {
$(this).html('<i class="fas fa-sync fa-spin"></i> Converting..');
}
$.post('/ajax', {
id: id,
},function (e) {
if (e.status == 'success') {
button.data('status', true);
button.html('<i class="glyphicon glyphicon-download-alt"></i> Download');
button.attr('href', e.url);
button[0].click();
}else{
button.html(e.html);
button.attr('disabled', 'disabled');
}
});
}
});
});
thanks if anyone figureout error
2
Answers
Try to simplify and do NOT click the same button
You can simply play by disabling and enabling button
HTML
jQuery
Just add button.prop(‘disabled’, true); after var button = $(this); & button.prop(‘disabled’, false); after button[0].click();
Try: https://jsbin.com/hudiroj/edit?html,js,console,output