0

I am a beginner with javascript ajax, and all this web stuff.

I have a situation, similar to what was posted (and seemingly solved) in How to insert a a set of table rows after a row in pure JS

In my case, I have xmlhttp.responseText returning a set of TRs from an AJAX call. I need to add it to the end of a table on the page it is called from.

I was using document.getElementById("posts").innerHTML+=xmlhttp.responseText; It worked well on all except IE, and having read into it, I think I understand why (read this).

In your code snippet

function appendRows(node, html){  
    var temp = document.createElement("div"); 
    var tbody = node.parentNode; 
    var nextSib = node.nextSibling; 

    temp.innerHTML = "<table><tbody>"+html; 
    var rows = temp.firstChild.firstChild.childNodes; 

    while(rows.length){ 
        tbody.insertBefore(rows[i], nextSib); 
    } 
} 

What does node mean? I am trying to find where I can get that in my code.

1 Answer 1

0

node appears to be the TR that the other table rows will be inserted after.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Justin. Though I have nt achieved any results yet. learning by trial and error. I thought I would simplify the question, if one of the experts can point me in the right direction. I have ' xmlhttp.responseText="<tbody><tr><td> a</td><td> b</td></tr><tr><td> c</td><td> d</td></tr></tbody>";' Seems to append to existing table in all but IE using document.getElementById("posts").innerHTML+=xmlhttp.responseText; Do I need to do anything more specific? Anyone? Thx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.