这里使用JQuery,但是老版本的JQuery比如1.2是不支持的,最好使用2.0或更新版本:
- <div class="modal fade bs-example-modal-sm1" tabindex="-1" role="dialog" aria-hidden="true">
@H_404_71@ <div class="modal-dialog modal-sm1">
@H_404_71@ <div class="modal-content">
@H_404_71@ <div class="modal-header">
@H_404_71@ <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
@H_404_71@ <h4 class="modal-title" id="myModalLabel2">机器信息导入</h4>
@H_404_71@ </div>
@H_404_71@ <div class="modal-body">
@H_404_71@
@H_404_71@ <form id="excelImportForm">
@H_404_71@ <table class="table table-striped table-bordered dataTable no-footer">
@H_404_71@ <tbody>
@H_404_71@ <tr>
@H_404_71@ <td style="text-align: center;font-size:20px;font-weight:700">文件</td>
@H_404_71@ <td><input type="file" name="fileName"/></td>
@H_404_71@ <td><input type="hidden" name="type" value="machInfo"/></td>
@H_404_71@ </tr>
@H_404_71@ </tbody>
@H_404_71@ </table>
@H_404_71@ </form>
@H_404_71@ </div>
@H_404_71@ <div class="modal-footer">
@H_404_71@ <button type="button" class="btn btn-default" data-dismiss="modal" id="cancelId">取消</button>
@H_404_71@ <button type="button" class="btn btn-primary" data-dismiss="modal" onclick="machInfoImport()">导入</button>
@H_404_71@ </div>
@H_404_71@ </div>
@H_404_71@ </div>
@H_404_71@ </div>
-
function machInfoImport(){ var formData= new FormData($("#excelImportForm")[0]); $.ajax({ type:'POST',url:'/fudaMes/excel/importExcel',data:formData,async: false,cache: false,contentType: false,processData: false,//必须要 success: function (data) { if(data=="success"){ new PNotify({ title:'导入成功',text: '机器信息导入成功',type: 'success',styling: 'bootstrap3' }); }else{ new PNotify({ title:'导入失败',text: ''+data,type: 'error',styling: 'bootstrap3' }); } $(".modal-backdrop").remove(); $("body").removeClass('modal-open'); $('body').removeAttr("style") $('body').css('display','block'); load_orderInfo(); },error: function (data) { console.log(JSON.stringify(data)) } }); }