接下来是这个问题
这工作:
<body onbeforeunload= "ajaxRequest('UnlockQuery.ashx?QueryID=266&UserID=11631');">这是在aspx页面中使用以下内容创建的:
<body onbeforeunload= "ajaxRequest('UnlockQuery.ashx?QueryID=<%= Session["QueryId"] %>& UserID=<%= Session["UserID"] %>')">这不起作用:
<body id="uxBodyTag" onbeforeunload= "ajaxRequest('UnlockQuery.ashx?QueryID=266&UserID=11631');">这是通过使用
uxBodyTag.Attributes["onbeforeunload"] += "ajaxRequest('UnlockQuery.ashx?QueryID=" + queryId.ToString() + "&UserID=" + Session["UserID"].ToString() + "');";被调用的代码是这样的:
function ajaxRequest(url) { xmlhttp=null; if (window.XMLHttpRequest) { // code for all new browsers xmlhttp=new XMLHttpRequest(); } else if (window.ActiveXObject) { // code for IE5 and IE6 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } if (xmlhttp!=null) { xmlhttp.onreadystatechange=null; xmlhttp.open("GET",url,true); xmlhttp.send(null); } }编辑:
它看起来只会在后续调用相同的解锁时失败。 我认为这可能是一个AJAX问题....
This follows on from this question
This was working:
<body onbeforeunload= "ajaxRequest('UnlockQuery.ashx?QueryID=266&UserID=11631');">This was created using the following in the aspx page:
<body onbeforeunload= "ajaxRequest('UnlockQuery.ashx?QueryID=<%= Session["QueryId"] %>& UserID=<%= Session["UserID"] %>')">This is not working:
<body id="uxBodyTag" onbeforeunload= "ajaxRequest('UnlockQuery.ashx?QueryID=266&UserID=11631');">This is created using:
uxBodyTag.Attributes["onbeforeunload"] += "ajaxRequest('UnlockQuery.ashx?QueryID=" + queryId.ToString() + "&UserID=" + Session["UserID"].ToString() + "');";The code being called is this:
function ajaxRequest(url) { xmlhttp=null; if (window.XMLHttpRequest) { // code for all new browsers xmlhttp=new XMLHttpRequest(); } else if (window.ActiveXObject) { // code for IE5 and IE6 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } if (xmlhttp!=null) { xmlhttp.onreadystatechange=null; xmlhttp.open("GET",url,true); xmlhttp.send(null); } }EDIT:
It appears to only fail when subsequent calls are made to the same unlock. I think this may be an AJAX issue....
最满意答案
添加
&date=DateTime.now.Ticks.ToString()似乎已经修复它。 我不认为当相同的AJAX调用进来并且前一个没有被“解析”(该页面在AJAX调用返回之前被放置)时,IE7喜欢它。
感谢所有提供的帮助。
Adding
&date=DateTime.now.Ticks.ToString()seems to have fixed it. I don't think IE7 likes it when the same AJAX call comes in and the previous hasn't been "resolved" (the page is disposed before the AJAX call returns).
Thanks to all that provided help.
更多推荐
发布评论