在ASP MVC FileResult返回后触发的JavaScript [英] Trigger javascript after FileResult return in ASP mvc

查看:623
本文介绍了在ASP MVC FileResult返回后触发的JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个JavaScript调用:

I have a Javascript call:

window.location.replace(instanceExtension(baseURL + "/AccountsReceivable/PrintStatementOfAccount?clientId=" + clientId, -1));

所以,我添加了指示面具到页面PrintStatementOfAccount()方法需要几秒钟的PrintStatement加载。

And the PrintStatementOfAccount() method takes a few seconds so I've added a mask to the page indicating that the PrintStatement is loading.

ASP的方法被定义为:

The ASP method is defined as:

public FileResult PrintStatementOfAccount(long clientId) { ... }

所有的伟大工程,但我想禁用等待面膜一旦文件的回报。我如何能做到这一点任何想法?

All works great, but I would like to disable the wait mask once the file returns. Any ideas on how I can achieve this?

推荐答案

您不能从JavaScript知道文件是否被返回给浏览器。

You cannot know from JavaScript whether the file is returned to the browser.

作为一种解决办法,而不是返回直接将文件拆分的过程:

As a workaround instead of returning the file directly you split the process:


  1. 文件可供下载:用某种方式识别文件中的参数重新加载在同一页

  2. 在重装你看的参数,并将其保存在一个JavaScript值。在这里,您可以隐藏等待面膜。

  3. 在页面中,您检查JavaScript文件标识符不为空,如果不是你做一个GET请求到服务器使用JavaScript window.location的文件='url_to_get_file'。

这篇关于在ASP MVC FileResult返回后触发的JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆