Safari和ASP.NET AJAX PageRequestManager.add_endRequest函数不总是触发 [英] Safari and ASP.NET AJAX PageRequestManager.add_endRequest Function Not Always Firing

查看:349
本文介绍了Safari和ASP.NET AJAX PageRequestManager.add_endRequest函数不总是触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里是背景资讯。 ASP.NET 2.0网站与AJAX扩展1.0。



我有一个奇怪的问题,只发生在Safari和我只能假设Chrome,因为他们都使用WebKit。我也在网站中使用jQuery,但目前jQuery的参考只加载在一个页面上,所以我不认为这是问题。



我有一个友好处理请求...消息,当您提交页面异步或非异步回发),并在回发后隐藏。在异步回发的情况下,我使用 PageRequestManager add_endRequest(...)方法隐藏处理请求...消息。这工作伟大在FireFox,IE 6/7/8和Opera,但由于某些原因在Safari(Windows和Mac版本), add_endRequest(...)不总是火。我是关于跨浏览器,所以只是想知道如果有人有任何想法如何解决这个。



这是一个显示停止我,因为不仅处理请求...消息,但我还在整个页面的顶部放置一个透明的div,以防止提交后多次点击,所以除非你知道如何破解CSS隐藏透明div。 p>

这是从我的主页的标记我的处理我的处理请求...消息的标记的代码片段:

 < asp:ScriptManager ID =ScriptManager1runat =server/> 
< script type =text / javascriptsrc =<%= ResolveClientUrl(〜/ Script / aspNetAjaxFix.js)%>>< / script&
< script type =text / javascript>
(function(){
var processingID =<%= processing.ClientID%>
var prm = Sys.WebForms.PageRequestManager.getInstance();

if(prm)
{
prm.add_endRequest(
function(sender,args){
// alert('Fired!')
if ('processAsyncProcessingWindow'])
{
setTimeout(function(){document.getElementById(processingID).className =LockOff; document.getElementById('processMe')className ='processMeLockOff'; if(typeof(showIE6Selects)!=undefined){showIE6Selects();}},1000);
top ['showAsyncProcessingWindow'] = false;
}

(args.get_error()&& args.get_error()。name ==='Sys.WebForms.PageRequestManagerServerErrorException')
{
args.set_errorHandled(args._error.httpStatusCode == 0) ;
}
});
}
})();
< / script>

如果你想知道aspNetAjaxFix.js是什么,请看这个问题我贴在StackOverFlow, a href =http://stackoverflow.com/questions/757758/internet-explorers-operation-aborted-and-latency-issue> Internet Explorer的操作中止和延迟问题



我也Googled这当然没有多少运气。本文似乎与您相关, http://forums.asp.net/t/1247957.aspx ,但只提出同样的问题,没有解决方案。



对这个问题的深入了解将非常感激。

解决方案

经过一些更多的挖掘,我发现了问题。它与 PageRequestManager add_endRequest(...)方法无关,与浏览器检测有关在ASP.NET AJAX客户端API的Safari和基于WebKit的浏览器。



感谢这个帖子从 taliesins net / members / taliesins.aspx nofollow noreferrer> http://forums.asp.net/t/1252014.aspx 。我发现这个帖子首先看到我得到这个错误:

  Sys.ScriptLoadFailedException:脚本'http:// localhost :2241 / WebResource.axd?d = hvpXhV5kEMwLgAoaIglURevR_XTtDTBoKZ3aZWWaIvEkBXbLudri1AIv5bRs5f6licjCZMs3Z3MioQLqLTXV98582pKDHkD7BucGkKsPLz41& t = 633444640020014740'无法加载。检查:
无法访问的路径。
脚本错误。 (IE)在高级设置下启用显示每个脚本错误的通知。
缺少对Sys.Application.notifyScriptLoaded()的调用。即使我正在调用 Sys.Application.notifyScriptLoaded()



c $ c>在我的JavaScript。



显示停止解决。


Here's the background info first. ASP.NET 2.0 Web Site with AJAX Extensions 1.0.

I have a weird issue that only occurs in Safari and I can only assume Chrome as well since they both use WebKit. I also use jQuery in the site, but currently the reference to jQuery is only loaded on one page so I don't think this is the issue.

I have a friendly "Processing Request..." message that appears when you submit a page async or non-async postback) and hides after postback. In the case of the async postback, I use the PageRequestManager's add_endRequest(...) method to hide the "Processing Request..." message. This works great in FireFox, IE 6/7/8 and Opera but for some reason on Safari (Windows and Mac versions), the add_endRequest(...) does not always fire. I'm all about the cross browser so just wondering if anyone has any ideas on how to fix this.

This is a show stopper for me because not only does the "Processing Request..." message appear, but I also put a transparent div on top of the entire page to prevent multiple clicks after submitting, so the page becomes unusable unless you know how to hack the CSS to hide the transparent div.

Here's the code snippet from my master page's markup of what I do to handle my "Processing Request..." message:

<asp:ScriptManager ID="ScriptManager1" runat="server" />
<script type="text/javascript" src="<%= ResolveClientUrl("~/Script/aspNetAjaxFix.js") %>"></script>
<script type="text/javascript" >
(function() {
    var processingID = "<%=processing.ClientID%>"
    var prm = Sys.WebForms.PageRequestManager.getInstance();

    if (prm)
    {
        prm.add_endRequest(
        function (sender, args) {
            //alert('Fired!')
            if (top['showAsyncProcessingWindow'])
            {
                setTimeout(function(){document.getElementById(processingID).className="LockOff";document.getElementById('processMe').className='processMeLockOff';if(typeof(showIE6Selects)!="undefined"){showIE6Selects();}}, 1000);
                top['showAsyncProcessingWindow'] = false;
            }

            if(args.get_error() && args.get_error().name === 'Sys.WebForms.PageRequestManagerServerErrorException')
            {
                args.set_errorHandled(args._error.httpStatusCode == 0);
            }
        });
    }
})();
</script>

And if you're wondering what aspNetAjaxFix.js is, see this question I posted on StackOverFlow, Internet Explorer's Operation Aborted and Latency Issue

I also Googled this of course with not much luck. This article seemed to be relevant ,http://forums.asp.net/t/1247957.aspx but only asks the same question, no solution.

Any insight into this issue would be greatly appreciated.

解决方案

Well after some more digging, I found out the issue. It has nothing to do with the PageRequestManager's add_endRequest(...) method and everything to do with Browser detection in the ASP.NET AJAX client-side API for Safari and WebKit based browsers.

Thanks to this post from taliesins on the ASP.NET forums, http://forums.asp.net/t/1252014.aspx. I found this post by first seeing that I was getting this error:

Sys.ScriptLoadFailedException: The script 'http://localhost:2241/WebResource.axd?d=hvpXhV5kEMwLgAoaIglURevR_XTtDTBoKZ3aZWWaIvEkBXbLudri1AIv5bRs5f6licjCZMs3Z3MioQLqLTXV98582pKDHkD7BucGkKsPLz41&t=633444640020014740' failed to load. Check for:
Inaccessible path.
Script errors. (IE) Enable 'Display a notification about every script error' under advanced settings.
Missing call to Sys.Application.notifyScriptLoaded().

even though I was calling Sys.Application.notifyScriptLoaded() in my JavaScript.

Show stopper resolved.

这篇关于Safari和ASP.NET AJAX PageRequestManager.add_endRequest函数不总是触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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