title: Confused about the action tag
body: <p>I've got an html page with a form set up as follows:</p>
  
  <pre><code>&lt;form name="form" action="process.php" method="POST"&gt;
      Username: &lt;input type="text" name="user"&gt;
      &lt;br&gt;
      Password: &lt;input type="text" name="pass"&gt;
      &lt;br&gt;
      &lt;input type="submit" value="LOGIN"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>When I click my submit button, the data is sent to my process.php script, and that's all well and good.</p>
  
  <p>But what I'd like to do is send a JSON string to a PHP script instead, and have that PHP script parse it.
  As such I tried the following:</p>
  
  <pre><code>&lt;body&gt;
  PLEASE ENTER YOUR INFORMATION:
  &lt;form name="form" action=""&gt;
      Username: &lt;input type="text" name="user"&gt;
      &lt;br&gt;
      Password: &lt;input type="text" name="pass"&gt;
      &lt;br&gt;
      &lt;input type="submit" value="LOGIN" onclick="encrypt(this.form, 0)"&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  
  
  &lt;script LANGUAGE="JavaScript"&gt;
  
  function encrypt(form, key){
  
      var user = form.user.value;
      var pass = form.pass.value;
      var str = {"username": user, "encrypted_password": pass};
      var JSON_str = JSON.stringify(str);
  
      var xhr = new XMLHttpRequest();
      xhr.open("POST", "process.php", true);
      xhr.send(JSON_str);
  
  }
  
  &lt;/script&gt;
  </code></pre>
  
  <p>Yet this doens't do anything. When I click the submit button nothing happens. Even if I could just get process.php to display something when I click the submit button, that would be enormously helpful.</p>
  
  <p>Thanks!</p>