title: how to save data form input to json file with javascript?
body: <p>This is my code but doesn't work. How do I save data form inputs to json file and send to server?</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Registration&lt;/title&gt;
      &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"&gt;
  
  &lt;!-- Optional theme --&gt;
  &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous"&gt;
  
  &lt;!-- Latest compiled and minified JavaScript --&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;form id="myform" action="register.json"&gt;
      &lt;label&gt;Vesete ime&lt;/label&gt;
      &lt;input type="text" name="name" value="name"&gt;
      &lt;label&gt;Vnesete password&lt;/label&gt;
      &lt;input type="password" name="password" value="password"&gt;
      &lt;button id="btn" type="submit" value="submit"&gt;Potvrdi&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>This is my script</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
          var x ={ "name":" ", "password":" "};
          var myJSON = JSON.stringify(x);
          document.getElementsByTagName("input").innerHTML = myJSON; 
          var xhr = new XMLHttpRequest();
      xhr.open('POST', 'register', true);
      xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
      xhr.onload = function () {
  
          console.log(this.responseText);
      };
      xhr.send('name=name&amp;password=password');
      &lt;/script&gt;
  </code></pre>
  
  <p>in the browser show this file:///var/www/html/register.json?name=marina&amp;password=1234567 but not save in json file. Plese help me in the first tame work with json.</p>