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