在提交表格之后返回一条消息

发布于 2025-02-06 17:40:53 字数 2137 浏览 1 评论 0原文

我在html中有此表格:

<form action='@Url.Action("ExportExcel", "Banks")' method="post" target="_blank" id="myForm">
    @Html.AntiForgeryToken()

        <input type="hidden" name="typeDetails" id="typeDetails" value="typeDetails.value" />
        <input type="hidden" name="filteredBanksIds" id="filteredBanksIds" value="" />
        <input id="btnExportExcel" type="hidden" value="submit" data-toggle="modal" data-target="#ExportExcelModal" />
</form>

而模式是:

<div class="modal fade" id="ExportExcelModal" tabindex="-1" role="dialog" aria-labelledby="ExportExcelModalTitle" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="ExportExcelModalTitle">Banks</h5>
                <button type="button" class="close" id="ExportExcelModalClose" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                Would you like to export this banks with details?
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-target="#myModal" value="1" onclick="exportExcel(this.value)">yes</button>
                <button type="button" class="btn btn-primary" data-target="#myModal" value="0" onclick="exportExcel(this.value)">no</button>
            </div>
        </div>
    </div>
</div>

我在JS中有此形式:

function exportExcel(typeDetails) {
    $('#ExportExcelModalClose').click();
    $('#filteredBanksIds').val(filteredBanks.map(function (bank) { return bank.Id }));
    $('#typeDetails').val(typeDetails);
    $("#myForm").submit;
    return true;
    }

除了服务器端发生的事情(Excel Export and download)外,我

还希望将其发送给用户。 Excel导出结束,并带有服务器的自定义消息。

我该如何添加?

I have this form in html:

<form action='@Url.Action("ExportExcel", "Banks")' method="post" target="_blank" id="myForm">
    @Html.AntiForgeryToken()

        <input type="hidden" name="typeDetails" id="typeDetails" value="typeDetails.value" />
        <input type="hidden" name="filteredBanksIds" id="filteredBanksIds" value="" />
        <input id="btnExportExcel" type="hidden" value="submit" data-toggle="modal" data-target="#ExportExcelModal" />
</form>

and the modal is:

<div class="modal fade" id="ExportExcelModal" tabindex="-1" role="dialog" aria-labelledby="ExportExcelModalTitle" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="ExportExcelModalTitle">Banks</h5>
                <button type="button" class="close" id="ExportExcelModalClose" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">×</span>
                </button>
            </div>
            <div class="modal-body">
                Would you like to export this banks with details?
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-target="#myModal" value="1" onclick="exportExcel(this.value)">yes</button>
                <button type="button" class="btn btn-primary" data-target="#myModal" value="0" onclick="exportExcel(this.value)">no</button>
            </div>
        </div>
    </div>
</div>

and I have this in JS:

function exportExcel(typeDetails) {
    $('#ExportExcelModalClose').click();
    $('#filteredBanksIds').val(filteredBanks.map(function (bank) { return bank.Id }));
    $('#typeDetails').val(typeDetails);
    $("#myForm").submit;
    return true;
    }

I would like that in addition to what happens on the server side (Excel export and download),

also a message will be returned to the user after the Excel export ends, with custom message from the server.

How can I add this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文