本文介绍了优雅地取消一个Ajax请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个更新面板和一个计时器页面。页更新基于定时器每隔5分钟。我也有一些javascript,强制更新面板上的__doPostBack如果另一页(从原来的发射)是封闭的。我想我遇到的问题是有时不得不回后似乎中断由它产生错误定时器触发回发。有没有办法取消当前回发再掀?或者检测是否回传正在进行?如果这甚至是一个问题。

I have a page with an update panel and a timer. The page updates every 5 minutes based on the timer. I also have some javascript that forces a __doPostBack on the update panel if another page (launched from the original) is closed. The problem I think I'm having is sometimes the forced post back seems to interrupt the postback triggered by the timer which is creating errors. Is there a way to cancel the current postback and start another? or detect if a postback is under way? Should this even be a problem

推荐答案

是的,你可以取消...

yes, you can cancel...

function CancelPostBack() {

var objMan = Sys.WebForms.PageRequestManager.getInstance();

if (objMan.get_isInAsyncPostBack())

    objMan.abortPostBack();

}

参考网址
<一href="http://www.$c$cdigest.com/Articles/ASPNETAJAX/125%5FUsing%5FUpdateProgress%5FControl%5FEffectively.aspx">http://www.$c$cdigest.com/Articles/ASPNETAJAX/125_Using_UpdateProgress_Control_Effectively.aspx

Reference URL
http://www.codedigest.com/Articles/ASPNETAJAX/125_Using_UpdateProgress_Control_Effectively.aspx

这篇关于优雅地取消一个Ajax请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 06:31
查看更多