jquery ajax element.children.length not getting updated -


we making ajax call every 5 seconds intent of appending content existing parent element. parent element has max of 25 elements above removed beginning of parent element. works expected except console.log call make output contentlength. contentlength keeps increasing in size , yet should @ 25. assume has fact making ajax call , dom length "incorrect" @ point inside ajax call. doing wrong? how can around this?

    ajs.$.ajax({         url: "ajax.action?",         success: function (data) {                               //cleanup , insert parent div                 var divid   = "#" + insertcontentintodiv;                 var wrapped = ajs.$("<div>" + data + "</div>");                 ajs.$(wrapped).find('title').remove().end();                 wrapped     = ajs.$(wrapped).find('meta').remove().end();                 ajs.$(divid + " dt:last-child").after(wrapped.html().trim());                  //remove whitespace pre-pended parent element                 cleanwhitespacefromelement(insertcontentintodiv);                  //remove child elements starting @ beginning                 var parentelement = document.getelementbyid(insertcontentintodiv);                 if(parentelement){                      var contentlength = parentelement.childnodes.length;                      console.log("________________cont: " + contentlength);                     if(contentlength > 0){                          var difference = contentlength - maxdisplayedlines;                         console.log("___________removing: " + difference);                         if(difference > 0){                             ajs.$(divid + " dt:lt(" + difference + ")").remove();                         }                     } else {                         console.log("elementid " + insertcontentintodiv + " appears have no children. expected?");                     }                 } else {                     console.log("elementid " + insertcontentintodiv + " not found. log parsing not done");                 }         },         datatype: 'html'     }); 


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -