Why is the html() function from Ajax creating an infinite loop?

I want to output an animation while the database operation is in progress. When the db operation is finished, the contents of the table in the html document will be modified.

  var jobj = new Object();
  jobj.uid = <?php echo "'".$_SESSION['user_id']."'";?>;
  var jsoninfo = JSON.stringify(jobj); 
  var table_content = '';

    contentType : 'application/json; charset=UTF-8',
    data : jsoninfo,
      var parse_data = JSON.parse(data);
      var array_unik = parse_data.shift();
      var array_heat = parse_data.shift();
      var f_omni = parse_data.shift();
      var i = 0;
      var j = 0;      
      table_content = $('#tblReport').html();
      table_content += some_text;
      document.getElementById('Load').style.visibility = "hidden";     


However, when I call the html () function inside an ajax code, it will fall into an infinite loop even though there is no loop.

Console output

Answers 1

  • Remove your ajax from any php/js loop, remove any setInterval function you have in the code,

    When you bind the ajax to a event you need to make sure the event isn't in a loop/setInterval/another event

Related Articles