c# - 从 jquery 下载具有现有路径的文件的最简单方法?

标签 c# javascript jquery asp.net-mvc

关于“如何从 jQuery 下载文件”的问题,我浏览了几十页,但仍然没有找到简单的解决方案。

我的 jQuery 里面有 ajax:

$.ajax({
     url: "/Home/SaveQBMatter",
     type: "POST",
     data: JSON.stringify({ 'Matters': result, 'originalRecords': originalRecords, 'originalHours': originalHours, 'excludedHours': excludedHours, 'totalHours': totalHours }),
     dataType: "json",
     traditional: true,
     contentType: "application/json; charset=utf-8",
     success: function (data) {
           if (data.status == "Success") {
                var DownloadableFile = data.message;

                //HERE I NEED TO DOWNLOAD FILE

                alert("Success! You will be redirect to the Home Page.");
                var url = '@Url.Action("Index", "Home")';
                window.location.href = url;
           } else {
                alert("Error occurs on the Database level!");
           }
     },
     error: function () {
           alert("An error has occured!!!");
     }
});

data.message 中,我正在从 Action SaveQBMatter 完整文件路径中返回

我需要的只是让我的用户在重定向之前下载这个文件。有什么帮助吗?

注意:如果需要此信息,我正在使用 ASP.NET MVC

最佳答案

关于c# - 从 jquery 下载具有现有路径的文件的最简单方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20336594/

相关文章:

c# - 获取定义方法的类?

javascript - 为什么一个只有一个数字的数组在 Javascript 中是一个数字?

在文本框上按回车键后的javascript函数

php - 如何使用ajax提交表单后重新加载数据表?

c# - iOS 运行错误 s Xamarin Live Player 和 Hanselman.Forms

c# - 在 C# 中重命名文件

c#: 元素 'Id' 不匹配任何字段或属性 MongoDB

javascript - Yii2 Ajax 过滤器 onblur

javascript - 如何使用 jQuery 循环访问 WordPress WP_Query 对象?

jquery - 以编程方式取消选中 jQuery UI 复选框按钮