ShawnMolloy
MIS
I'm trying to learn to code "AJAX" types of functionality through javascript and the Microsoft.XMLHTTP object. I'm finding it terribly difficult to debug. Please take a look at the below code; this code never seems to get called:
http.onreadystatechange = handleCommentResponse;
When the sndComment() function is called it updates my div, but never seems to reach the handleCommentResponse() function, even though it is very straight forward (for testing purposes). Can someone take a look and help me figure out what I'm missing:
Thank you very much!
Shawn Molloy
Seattle, WA
http.onreadystatechange = handleCommentResponse;
When the sndComment() function is called it updates my div, but never seems to reach the handleCommentResponse() function, even though it is very straight forward (for testing purposes). Can someone take a look and help me figure out what I'm missing:
Code:
var http = createRequestObject();
function createRequestObject()
{
var xmlhttp;
try
{
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
catch(f) { xmlhttp=null; }
}
if(!xmlhttp&&typeof XMLHttpRequest!="undefined")
{
xmlhttp=new XMLHttpRequest();
}
return xmlhttp;
}
// SEND THE COMMENT
function sndComment(idnum,comment)
{
var dvelement = document.getElementById('dv_Comment');
dvelement.innerHTML = "<br><div style='color: black; padding: 10px; margin: 10px; font-color: black;'><br>Adding Comment<br><img src='img/progressimgred.gif'></div>";
try
{
http.open('GET', 'video/addComment.aspx?id='+idnum+'&rateval='+rateval);
http.onreadystatechange = handleCommentResponse;
http.send(null);
}
catch(e){}
finally{}
}
// Handle the http response
function handleCommentResponse()
{
var dvelement = document.getElementById('dv_Comment');
dvelement.innerHTML = "SomeText!";
alert('asdf');
}
Thank you very much!
Shawn Molloy
Seattle, WA