Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9277001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:59:29+00:00 2026-06-18T16:59:29+00:00

My code: function SubmitCommentAJAX(i) { var thecomment = i.parentNode.getElementsByClassName(styled)[0].innerHTML; var commentBox = document.body.getElementsByClassName(commentsScroll)[0]; var

  • 0

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 get error: NOT_FOUND_ERR: DOM Exception 8 for the line commentBox.insertBefore(response, commentBox.firstChild);

But commentBox is well defined because when I check with alert(commentBox) it shows me the object.

What is the mistake?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T16:59:30+00:00Added an answer on June 18, 2026 at 4:59 pm

    insertBefore takes a dom node so you’ll have to convert the text to a text node

    var response=xmlhttp.responseXML.getElementsByTagName("theComment")[0].textContent;
    commentBox.insertBefore(document.createTextNode(response), commentBox.firstChild);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote this code: function json() { var url=http://192.172.2.23:8080/geoserver/wfs?request=GetFeature&version=1.1.0&outputFormat=json&typeName=topp:networkcoverage&CQL_FILTER= topp:CELL_ID='410-07-301-31781' Or topp:CELL_ID='nnn'&callback=?; jQuery.getJSON(url,function(data){alert(Symbol: +
This is my code: function text(var text) { var Value = document.getElementById(display).innerHTML; var New
My Code: function HandleSignUp() { var CurrentURL = document.URL; var obj, val; //ajax call
Updated code: function getElements() { var x=document.getElementsByTagName("option"); var el = document.getElementById('selectDept'); el.onmouseover = function(
My Code: function onLoad(e) { var element = document.getElementById('cmbGender'); $.ajax({ type: POST, url: @(Url.Action(LoadGenderNames,
Here is my simple code: function save_edit(res,table_color) { var the_form="details_"+res; alert(document.the_form.title.value); } All I
I have some Javascript code: function addRow(tableID, rowId) { var table = document.getElementById(tableID); var
Here is my validation code: function validateEnquiryForm() { var x = document.forms[enquiry][name].value; if(x ==
I have this code : function move() { $(document).mousemove(function(e){ var x = e.pageX; $('.linkHover').animate({'right':
This is my code: function deleteHostTable(src) { var table = src.parentNode.parentNode.parentNode; if(table.rows.length > 1)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.