title: Javascript functions not fetching data on load
body: <p>I'm having an issue with the code I have provided below and I'm new to Javascript and Jquery.  What the code is supposed to do is on load it fetches a number for "unread notifications" then places that number in a div called notes_number.  Then it should read the number from notes_number and depending on if the number is more than 0 it will show the div called notes_signal.</p>
  
  <p>I do this on load, every 5 seconds, and then whenever the notifications button is pressed.  The code isn't working because on load it doesn't put a number in the notes_number div.  Also the other occurrences aren't working.  At one point I thought it was working but now I can't figure out what's up.  Here's the code:</p>
  
  <pre><code>//THIS IS TO CHECK WHEN THE PAGE COMES UP
  $("#notes_number").load("getnumber.php");
  
  if(document.getElementById("notes_number").innerHTML &gt; 0){
  var elem = document.getElementById("notes_signal");
  elem.style.display = "";
  }
  
  if(document.getElementById("notes_number").innerHTML == 0){
  var elem = document.getElementById("notes_signal");
  elem.style.display = "none";
  }
  
  
  //THIS IS TO CHECK EVERY 5 SECONDS
  window.setInterval(function(){
  $("#notes_number").load("getnumber.php");
  
  if(document.getElementById("notes_number").innerHTML &gt; 0){
  var elem = document.getElementById("notes_signal");
  elem.style.display = "";
  }
  
  if(document.getElementById("notes_number").innerHTML == 0){
  var elem = document.getElementById("notes_signal");
  elem.style.display = "none";
  }
  }, 5000);
  
  
  
  //THIS IS TO CHECK WHEN THE BUTTON IS PRESSED
  function toggleDiv(divId) {
     $("#"+divId).show();
  
  $(document).ready(function(){
     $("#myContent").load("getnotes.php?page=&lt;? echo $page; ?&gt;");
  });
  
  
  
  $("#notes_number").load("getnumber.php");
  
  if(document.getElementById("notes_number").innerHTML &gt; 0){
  var elem = document.getElementById("notes_signal");
  elem.style.display = "";
  }
  
  if(document.getElementById("notes_number").innerHTML == 0){
  var elem = document.getElementById("notes_signal");
  elem.style.display = "none";
  }
  }
  </code></pre>