title: ajax jquery update page without refreshing
body: <p>I currently have the below function which updates the data in a div when the page is refreshed and this works fine however i want to edit the function to make it constantly update say every 2 seconds without having to refresh the page. How would i go about doing this?</p>
  
  <pre><code>&lt;script&gt;
      $(document).ready(function ajaxLoop() {
          //-----------------------------------------------------------------------
          // Send a http request with AJAX Jquery
          //-----------------------------------------------------------------------
          $.ajax({
              url: 'getOrderStatus.php', // Url of Php file to run sql         
              data: "",
              dataType: 'json', //data format      
              success: function ajaxLoop(data) //on reciept of reply
                  {
                      var OrdersSubmitted = data[0].SUBMITTED; //get Orders Submitted Count
                      var OrdersFulfilled = data[0].FULFILLED; //get Orders Fulfilled count
                      //--------------------------------------------------------------------
                      // 3) Update html content
                      //--------------------------------------------------------------------
                      $('#OrdersSubmitted').html("SUBMITTED:" + OrdersSubmitted);
                      $('#OrdersFulfilled').html("FULFILLED:" + OrdersFulfilled); //Set output html divs
                  }
          });
      });
  &lt;/script&gt;
  </code></pre>