Solution 1 :

you should avoid while(true). it is better to use setInterval

setInterval(()=>{
        $(document).ready(function calllog(){
          $.ajax({
            type : 'GET',
            url : '/for_log',
            dataType : 'text',
            error : function(){
              alert("failed");
            },
            success : function(data){
              document.getElementById("demo").append(data);
              }
            }
          });
        }
        } , 1000); // every second

this is another way to solve this problem recursive ajax

Problem :

This is my first time using Ajax, and I use endless loop ajax’s request to get data from python function.
I want to display the data in html table, but when ajax does loop, screen is loading and nothing displays.
This is my ajax code.

  <td height="50%"style="border-width:5px; border-color:black; border-style: solid">
    <p id = "demo">hihi</p>
      <script>
      while(True){
        $(document).ready(function calllog(){
          $.ajax({
            type : 'GET',
            url : '/for_log',
            dataType : 'text',
            error : function(){
              alert("failed");
            },
            success : function(data){
              document.getElementById("demo").append(data);
              }
            }
          });
        }
        });

How can the screen be printed while receiving and writing data without continuing to load the screen?

By