title: Stop form from refreshing the page on submit
body: <p>Alright, so I have a basic form on my page:</p>
  
  <pre><code>        &lt;form action='' id='formId' method='POST'&gt;
          &lt;table&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      &lt;input type='text' name='Chat' autocomplete='off'&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;input type='submit' name='Go'&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>and the javascript is:</p>
  
  <pre><code>        &lt;script type='text/javascript'&gt;
          $( "#formId" ).submit(function( event ) {
            event.preventDefault();
                  &lt;?php
  
                      $Chat = mysql_real_escape_string(strip_tags($_POST['Chat']));
                      $Go = mysql_real_escape_string($_POST['Go']);
  
                      if ($Go) {
  
                          if ($Chat) {
  
                              mysql_query("INSERT INTO `Chat` (`Chat`)
                              VALUES('$Chat')");
                          }
  
                      }
  
                  ?&gt;
          });
      &lt;/script&gt;
  </code></pre>
  
  <p>I just need it to stop from refreshing when someone submits. I've read a few different posts on here with the same problem, but none seemed to work for me.</p>