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....