AppendChild not working in Ajax request

前端 未结 2 1944
轻奢々
轻奢々 2021-01-07 13:00

I have a script to add an input field element when a current one is pressed. When i use innerHTML it replaces the current, which is not what i want. So I figured appendChild

相关标签:
2条回答
  • 2021-01-07 13:24

    parent.appendChild() is a function waiting for DomNode Object and you are passing a String, it can't work...

    Try :

    var d = document.createElement('div');
    d.innerHtml = xmlhttp.responseText;
    document.getElementById("org_div1").appendChild(d);
    
    0 讨论(0)
  • 2021-01-07 13:45

    AppendChild expects an object, where innerHTML works with a String. And since your server returns partial HTML, this will only work with innerHTML.

    0 讨论(0)
提交回复
热议问题