title: Ajax script to get chat messages
body: <p>I'm new to AJAX, and I'm trying to get some messages from a database for a shoutbox. This is my AJAX script:</p>
  
  <pre><code>var chatUpdate = function() {
      $.ajax({
          url: "/getChat",
          success: function(data) {
              // do something with "data"
              if (data.length &gt; 0) {
                  var page = $(data);
                  var time = page.find('#time').val();
                  console.log(time);
                  var now = Math.round((new Date()).getTime() / 1000);
                  if(now &gt;= time){
                  var statusText = page.find('#msg').val();
                  console.log(statusText);
                  $("#chatTable").append(statusText);
              }
              }
          },
          error: function(xhr, ajaxOptions, thrownError) {
              alert(thrownError);
          }
      });
  };
  
  setInterval(chatUpdate, 25000);
  </code></pre>
  
  <p>and what PHP does after it gets the data:</p>
  
  <pre><code>echo "&lt;div id='msg'&gt;&lt;tr&gt;&lt;td&gt;" .$row['username']. "&lt;hr style='margin:0; padding: 0;' /&gt;" .$row['msg']. "&lt;/td&gt;&lt;/tr&gt;&lt;/div&gt; &lt;div id='time'&gt;".$row['time']."&lt;/div&gt;";
  </code></pre>
  
  <p>but, in the console it says that neither statusText or time have a value. What would be causing this, because there's definitely data in the database. </p>