Is it safe to use innerHTML to make something like this:
newContent = ""; newContent += "<tr>"; newContent += "<td>" + data.fullname + "</td>"; newContent += "<td>" + data.fixedname + "</td>"; newContent += '<td class="text-center"><button id="id_'+a+'" type="button" class="btn btn-xsmall shadow-none">Button</button></td>'; newContent += "</tr>"; document.getElementById("myID").innerHTML += newContent; The data I get from ajax.
or this:
newContent = "<i class="fa fa-spinner fa-spin fa-fw"></i> Submitting ..."; document.getElementById("myID").innerHTML = newContent; If not what can I do to substitute it?
I am trying to use setHTML() instead of innerHTML, but I still don't know if I can replace innerHTML with that.
newContent = "<i class="fa fa-spinner fa-spin fa-fw"></i> Submitting ...";<-- This is syntactically invalid JavaScript: you need to escape the double-quotes used for attributes. PutnewContent = "<i class=\"fa fa-spinner fa-spin fa-fw\"></i> Submitting ...";instead.