I'm trying to catch the clicks on the links through out my site. I'm using XMLHttpRequest to save those clicks in database.
function GetXmlHttpObject() {
var objXMLHttp = null
if (window.XMLHttpRequest) {
objXMLHttp = new XMLHttpRequest()
}
else if (window.ActiveXObject) {
objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
}
function SubmitRequest(HighlightID) {
var url = "Redirect.aspx?MediaHighlightID=" + HighlightID;
xmlSaveItemHttp = GetXmlHttpObject();
if (xmlSaveItemHttp == null) {
return
}
// xmlSaveItemHttp.onreadystatechange = ChangeItemStatus
xmlSaveItemHttp.open("GET", url, true)
xmlSaveItemHttp.send(null)
}
The clicks get saved in all browsers except IE. In IE alternate clicks are getting saved. i.e. if I click on a link thrice then first and third clicks are saved but not the second one.
swarup
Member
17 Points
21 Posts
XMLHttpRequest()
Feb 10, 2012 10:56 AM|LINK
Hi,
I'm trying to catch the clicks on the links through out my site. I'm using XMLHttpRequest to save those clicks in database.
function GetXmlHttpObject() {
var objXMLHttp = null
if (window.XMLHttpRequest) {
objXMLHttp = new XMLHttpRequest()
}
else if (window.ActiveXObject) {
objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
}
function SubmitRequest(HighlightID) {
var url = "Redirect.aspx?MediaHighlightID=" + HighlightID;
xmlSaveItemHttp = GetXmlHttpObject();
if (xmlSaveItemHttp == null) {
return
}
// xmlSaveItemHttp.onreadystatechange = ChangeItemStatus
xmlSaveItemHttp.open("GET", url, true)
xmlSaveItemHttp.send(null)
}
<a href='<%#Convert.ToString(DataBinder.Eval(Container.DataItem, "ArticleURL"))%>' onclick="javascript:SubmitRequest(<%#Convert.ToString(DataBinder.Eval(Container.DataItem, "MediaHighlightID"))%>);" style="color:#333333" target="_blank"><%#Convert.ToString(DataBinder.Eval(Container.DataItem, "ArticleTitle"))%></a>
The clicks get saved in all browsers except IE. In IE alternate clicks are getting saved. i.e. if I click on a link thrice then first and third clicks are saved but not the second one.
Any suggestions or help is appreciated.
Regards
Swarup