title: Display random numbers from backend to frontend(browser) one by one or dynamically
body: <p>I have function that generate 10 numbers in my python script:</p>
  
  <pre><code>for x in range(10):
      time.sleep(5)
      return json.dumps({'rand': str(random.randint(1,101))});
  </code></pre>
  
  <p>when a button is click, this above is called via ajax:</p>
  
  <p><strong>Approach 1</strong> - below does print only one number in console.</p>
  
  <pre><code>  $.ajax({
          url: '/test',
          type: 'POST',
          success: function(response){
              var obj = JSON.parse(response);
                  console.log(obj.rand);
          }
      })
  </code></pre>
  
  <p><strong>Approach 2</strong> - adding <code>setInterval</code>, recalls function, but Im getting weird two numberspattern only</p>
  
  <pre><code>   94
      2
      94
      2
      ...
  </code></pre>
  
  <p>etc.</p>
  
  <pre><code> $.ajax({
              url: '/test',
              type: 'POST',
              success: function(response){
              setInterval(function() {
                  var obj = JSON.parse(response);
                      console.log(obj.rand);
              }, 5000);
              }
          })
  </code></pre>
  
  <p>My goal is to display random numbers from backend one by one (same sleep) to UI. Thanks in advance.</p>