title: Think something's wrong with my ajax?
body: <p>What I want to do is return the echo value of "addTemplate.php" when I send it a form value via a http POST request. However, when I send the request, absolutely nothing happens.</p>
  
  <p>What should I do?</p>
  
  <p>Here's my JS</p>
  
  <pre><code>$(document).ready(function() {
      $("#sendTemplate").on("submit", function(event) {
          var template = $("#template").val();
          event.preventDefault();
          $.ajax({method: "POST", url: "addTemplate.php", data: template, success: function(result) {
              alert(result);
          });
      });
  });
  </code></pre>
  
  <p>Here's my html</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;Admin&lt;/title&gt;
          &lt;link type="text/css" rel="stylesheet" href="stylesheet.css"&gt;
          &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"&gt;&lt;/script&gt;
          &lt;script src="adminscript.js"&gt;&lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;h1&gt;Admin/Developer page&lt;/h1&gt;
          &lt;form id="sendTemplate"&gt;
              &lt;p&gt;Enter a new template for the server: (Enter #word to enter a placeholder for words)&lt;/p&gt;&lt;input type="text" name="template" id="template"&gt;
              &lt;input type="submit" name="submit"&gt;
          &lt;/form&gt;
          &lt;div id='success'&gt;&lt;/div&gt;
          &lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;
          &lt;form action="turing.html"&gt;
              &lt;button type="submit"&gt;Home&lt;/button&gt;
          &lt;/form&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And here is my php</p>
  
  <pre><code>$template = $_POST["template"]; 
  if(strlen($template) &lt;= 100 &amp;&amp; strpos($template, "#word")) {
      file_put_contents("templates.txt", "\r\n" . $template, FILE_APPEND);
      header("Location: http://community.dur.ac.uk/h.j.g.baum/admin.html");
      echo "True";
  }
  else {
      echo "False";
  }
  </code></pre>
  
  <p>What's wrong with my code (most likely in the JavaScript) and how can I improve it?</p>
  
  <p>Thanks</p>