NOT_FOUND_ERR: DOM Exception 8 - javascript -
my code:
function submitcommentajax(i) { var thecomment = i.parentnode.getelementsbyclassname("styled")[0].innerhtml; var commentbox = document.body.getelementsbyclassname("commentsscroll")[0]; var request = "http://localhost:8080/ituned.com/index?event=comment&posttitle=<%=p.gettitle()%>&postowner=<%=p.getusername_of_owner()%>&comment="+thecomment; xmlhttp.open("post",request,true); xmlhttp.send(); xmlhttp.onreadystatechange=function() { if (xmlhttp.readystate==4 && xmlhttp.status==200) { var response=xmlhttp.responsexml.getelementsbytagname("thecomment")[0].text; **commentbox.insertbefore(response, commentbox.firstchild);** } }; }
html:
<div class="commentsscroll" align="left"> <div></div> </div> </div>
i error: not_found_err: dom exception 8 line commentbox.insertbefore(response, commentbox.firstchild);
but commentbox defined because when check alert(commentbox) shows me object.
what mistake?
insertbefore
takes dom node you'll have convert text text node
var response=xmlhttp.responsexml.getelementsbytagname("thecomment")[0].textcontent; commentbox.insertbefore(document.createtextnode(response), commentbox.firstchild);
javascript exception dom insertion
No comments:
Post a Comment