1
林:jquery.filedownloader不打完成或成功回調
return \PDF::loadView($view, $data)->download('Gender');
然後使用jQuery插件filedownloader下載文件(http://jqueryfiledownload.apphb.com/)
$(document).on('click','a#download-pdf', function(){
$(this).attr('disabled','disabled').html('<img src="{!! secure_url("/img/ajax-loader.gif",[]) !!}"/>');
$.fileDownload($(this).prop('href'), {
successCallback: function(url) {
$('#download-pdf').removeAttr('disabled').text('Download pdf');
},
failCallback: function (responseHtml, url) {
$('#download-pdf').removeAttr('disabled').text('Download pdf');
alert('PDF creation failed, please try again');
}
});
return false;
});
我也試過:
$(document).on('click','a#download-pdf', function(){
$(this).attr('disabled','disabled').html('<img src="{!! secure_url("/img/ajax-loader.gif",[]) !!}"/>');
$.fileDownload($(this).prop('href'))
.done(function(){
$('#download-pdf').removeAttr('disabled').text('Download pdf');
})
.fail(function(){ $('#download-pdf').removeAttr('disabled').text('Download pdf'); });
return false;
});
的文件正在成功下載,那麼爲什麼回調沒有被擊中?
文件正在下載成功,回調沒有被擊中 – Rob
是的,但它使用cookie + iframe使回調工作。檢查http://johnculviner.com/jquery-file-download-plugin-for-ajax-like-feature-rich-file-downloads/ http://johnculviner.com/jquery-file-download-plugin-for-ajax -like-feature-rich-file-downloads/ –
我曾遇到fileDownload.js的相同問題並以此方式解決 –