I'm trying to compare a jQuery returned string (accessed by msg.d) and another string. This is currently what I have done, but it seems like it's not working and saying it's not equal every time:
setTimeout(ReloadChatMsgs, 1000);
function ReloadChatMsgs() {
var msgs = document.getElementById("msgs_list");
$.when($.ajax({
type: "POST",
url: 'Login.aspx/ReloadChatMsgs',
data: '{}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
if (msgs.innerHTML != msg.d.toString())
msgs.innerHTML = msg.d;
},
failure: function (e) {
}
})).then(function () { setTimeout(ReloadChatMsgs, 1000); });
}
msgs.innerHTMLandmsg.dare defined? are you sure that the output ofmsg.d.toString()are what you expected?