title: Javascript listening for data changes & trigger reload
body: <p>I have a server sent event in PHP that displays inventory information client side and updates in real time. That part works great. The challenge is that I want to trigger a reload when the inventory = 0. Note: I'm using jQuery Mobile 1.4.5</p>
  
  <p>Here's my code: </p>
  
  <pre><code>var source = new EventSource('listener.php');
  source.onmessage = function(msg) {
  document.getElementById('inv').innerHTML = msg.data; 
  };
  
  source.addEventListener('msg', onMessageHandler,false);
  
  function onMessageHandler(msg) {
  var inventory = msg.data;
  };
  
  // Trying to Fire Something like this //
  //if (inventory = 0) {
  //setTimeout(function() {    
  //location.reload(true) 
  //},5000);
  </code></pre>
  
  <p>Thanks for any suggestions : )</p>