title: JQuery only refresh if form has been submitted realtime
body: <p>So I have a page that uses some JQuery to reload a php file every 15 seconds, nothing special. The php file simply echos that last 3 lines of a textfile.</p>
  
  <p>Here's the JQuery:</p>
  
  <pre><code>$(document).ready(function() {
      $("#realtime").load("realtime.php");
  
      var refreshId = setInterval(function() {
          $("#realtime").load('realtime.php');
      }, 15000);
      $.ajaxSetup({ cache: false });
  });
  </code></pre>
  
  <p>And lets just say for a clear example the PHP file is:</p>
  
  <pre><code>echo "&lt;li class='alternate'&gt;query 1&lt;/li&gt;";
  echo "&lt;li class='alternate'&gt;query 2&lt;/li&gt;";
  echo "&lt;li class='alternate'&gt;query 3&lt;/li&gt;";
  </code></pre>
  
  <p>I would like to achieve 2 things, firstly I would only like the PHP file to update when a form has been submitted in real time so it's not just updating every 15 seconds, I am guessing this will involve some kind of cache storage or something?</p>
  
  <p>Secondly you may have noticed the li class is named alternate because the colors alternate how would I be able to change this from odd to even when the form has recently been submitted also. Jquery so far is:</p>
  
  <pre><code>$(document).ready(function(){
      $('#myList li:nth-child(odd)').addClass('alternate');
  });
  </code></pre>
  
  <p>I have most of the pieces but placing them together is puzzling me although it may seem very simple, can anyone help? Thanks.</p>