javascript - Comparing jQuery returned string with another string -


i'm trying compare jquery returned string (accessed msg.d) , string. have done, seems it's not working , 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); }); } 

if want compare 2 strings irrespective of case

  1. trim both strings
  2. convert both lowercase

code:

if ($.trim(msgs.innerhtml.tolowercase()) != $.trim(msg.d.tostring().tolowercase()))     msgs.innerhtml = msg.d 

hope helps


Comments