weixin_33670713 2015-05-06 16:19 采纳率: 0%
浏览 18

表格提交不完整

So on my page, I have a button where user can export the data to EXCEL/PDF. The way it works is they click on the button and then I send the data into a hidden form which submits the request. Once the request is done, it returns the content of the document type that the user selected which prompts the "Save As" dialog.

<form id="export-form" action="laravel-excel.php" method="POST" target="hidden-form">
    <input type="hidden" name="type" value="{{header.export.type}}" />
    <input type="hidden" name="name" value="{{header.export.name}}" />
    <input type="hidden" name="data" value="{{header.export.data}}" />
</form>
<iframe style="display:none" name="hidden-form"></iframe> 

So everything works as it should! However, I want to add a loader to let people know that the file is processing and when its done, I want to hide it. Well based on my research I was unable to find a solution that works for forms. The solutions I found are ones where the processing happens via AJAX like so:

$('#export-form').ajaxForm({
success: function (response, status, request) 
{
    var disp = request.getResponseHeader('Content-Disposition');
    if (disp && disp.search('attachment') != -1) 
    {
       var type = request.getResponseHeader('Content-Type');
       var blob = new Blob([response], { type: type });
       var URL = window.URL || window.webkitURL;
       var downloadUrl = URL.createObjectURL(blob);
        window.location = downloadUrl;
    }
}});

Is there a better solution out there?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 网络设备配置与管理这个该怎么弄
    • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
    • ¥20 西门子S7-Graph,S7-300,梯形图
    • ¥50 用易语言http 访问不了网页
    • ¥50 safari浏览器fetch提交数据后数据丢失问题
    • ¥15 matlab不知道怎么改,求解答!!
    • ¥15 永磁直线电机的电流环pi调不出来
    • ¥15 用stata实现聚类的代码
    • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
    • ¥20 docker里部署springboot项目,访问不到扬声器