when i create new element "p" with javascript code and using php to get data from database. then i used form element over the html division in which i want to show data but when i fetech data form element work but data cannot display in division or anywhere in page it flickers, why?
function appendText(){
    
    const para = document.createElement("p");
    
    var str = '<?= $message; ?>'
     
    const node = document.createTextNode(str);
    
    para.appendChild(node);
    
    const element = document.getElementById("div1");
    
    element.appendChild(para);
    
}
this is my code for creating p element in division 1
<div id="div1">
      <p>Hi, how are you</p>
                    
</div>
<div class="footer">
   <form action="" method="post"> 
     <input type="text" class="text" name="data" placeholder="Enter Your Question Here" >
     <input type="submit" name="submit" class="button" value="submit"  id="send-btn" onclick="appendText()">
   </form> 
</div>
 
    