每X分钟自动触发一次asp.net mvc ajax刷新
我的页面上有一个刷新按钮,它将执行 asp.net mvc ajax post 来更新页面上的一些内容。刷新/更新过程可能会长时间运行(大约 10-20 秒)。现在用户必须手动单击“刷新”按钮才能触发刷新。我想每 X 分钟自动触发一次刷新。我几乎想触发与下面相同的 Ajax 帖子(并且也能显示 LoadingElementId 会很好)。
<% using (Ajax.BeginForm("Refresh", null,
new {userId=Model.UserId},
new AjaxOptions { UpdateTargetId = "UserForm", LoadingElementId = "RefreshingDiv" },
null))
{
%>
<button type="submit">
<img src="/zsys/img/icons/refresh.png" alt="Refresh" />
Refresh
</button>
<% } %>
如何强制 asp.net mvc ajax 回发?
I have a Refresh button on my page that will perform an asp.net mvc ajax post to update some of the content on the page. The refresh/update process can be long running (about 10-20 seconds). Right now the user has to manually click the Refresh button to trigger the refresh. I want to trigger the refresh automatically every X minutes. Pretty much I want to trigger this same Ajax post as below (and it would be nice to display the LoadingElementId too).
<% using (Ajax.BeginForm("Refresh", null,
new {userId=Model.UserId},
new AjaxOptions { UpdateTargetId = "UserForm", LoadingElementId = "RefreshingDiv" },
null))
{
%>
<button type="submit">
<img src="/zsys/img/icons/refresh.png" alt="Refresh" />
Refresh
</button>
<% } %>
How can I force the asp.net mvc ajax postback?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Wyatt Barnett 的回答让我尝试仅单击用户的“刷新”按钮。然后我使用 setInterval 每 5 分钟触发一次刷新按钮:
Wyatt Barnett's answer made me try just clicking the Refresh button for the user. And then I used setInterval to trigger the Refresh Button click every 5 minutes:
jQuery 计时器 +
call $('#form').submit()
应该可以解决问题。jQuery timer +
call $('#form').submit()
should do the trick.将 RefreshFormButton 放入 id 提交按钮中......那么 JS 函数就可以工作了。
Put the RefreshFormButton in the id submit button .... well you get the JS function to work.