title: Ajax Set timeout every second
body: <p>i am calling an ajax function every second to make an online class link live, if the class link is finished i need to display the last class until the current time matches with the scheduled class time which needs to be enabled live. so i called ajax function using set interval method, and it works fine but i am getting an error like 504 Gateway time out error and the whole site is not working. so can any one give me good suggestion please ?</p>
  <p>Below is my ajax code</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(function() {
    setInterval(updateLstream, 1000);
  });
  updateLstream();
  
  function updateLstream() {
    $.ajax({
      type: 'POST',
      async: true,
      url: "../users/zbbtns_live.php",
      data: {
        cid: ""
      },
      success: function(data) {
        if (data.status == 1) {
          $(".setMainLiveBtn").html(data.Hdata);
        } else {
          //alert("No Live Streams");
          console.log("ss");
        }
      }
    });
  }</code></pre>
  </div>
  </div>
  </p>