function OnSuccessPM(results) {
$("#ChatBox").html("");
for (var i = 0; i < results.length; i++) {
$("#ChatBox").append(results[i].username + " : " + results[i].message + ". <br />");
}
var objDiv = document.getElementById("ChatBox");
objDiv.scrollTop = objDiv.scrollHeight;
return false;
}
MetamorphismApp.ChatService.GetPublicMessages(OnSuccessPM, OnFailurePM);
[WebMethod(EnableSession = true)]
public List<Message> GetPublicMessages()
{
List<Message> getMsgsList = (List<Message>)HttpContext.Current.Application["Messages"];
return getMsgsList;
}
I get the following error in IE:
length is null or not an object.
What is the solution?
Simplest (but not the best, the best would be to fix what is being passed to your
OnSuccessPMfunction) way would be to check thetypeOftheresultsvariable to make sure it is an Array and only proceed to theresults.lengthline if it is.