1、找到一张loading图片
2、添加样式
<style> .loadingWrap{ position:fixed; top:0; left:0; width:100%; height:100%; z-index:300; background-image:url(${ctx}/webapp/img/loading.gif); background-repeat:no-repeat; background-position:center center; background-color:#000; background-color:rgba(0,0,0,0.5); filter:alpha(opacity=50); } </style>
3、ajax调用
function downloadTaskPackageRel(projectId){ $.ajax({ url : ctx + '/exportTaskPackageRel.do', type : 'POST', dataType : 'json', data : { projectId:projectId, }, success : function(data) { $("#msg").val(data.msg); downLoadExportFile(data.fileName); }, error : function() { }, beforeSend: function(){ $('<div class="loadingWrap"></div>').appendTo("body"); }, complete: function(){ $(".loadingWrap").remove(); } }); }
参考:https://blog.csdn.net/jwiang/article/details/52850703 感谢作者