title: How to store data from a form that POST a request to a remote URL
body: <p>I am using Javascript to create a post form.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
  function post_to_url(path, method) {
      method = method || "post"; // Set method to post by default, if not specified.
  
      // The rest of this code assumes you are not using a library.
      // It can be made less wordy if you use one.
      var form = document.createElement("form");
      form.setAttribute("method", method);
      form.setAttribute("action", path);
      form.setAttribute("id", "test");
  
      var hiddenField = document.createElement("input");
      hiddenField.setAttribute("type", "hidden");
      hiddenField.setAttribute("name", "brand_id");
      hiddenField.setAttribute("value", "23");
  
      form.appendChild(hiddenField);
  
      document.body.appendChild(form);
      form.submit();
  }
  
  post_to_url("http://www.bilpriser.se/wp-content/plugins/bilpriser_value/ajax.php/get_brand", "POST");
  
  &lt;/script&gt;
  </code></pre>
  
  <p>The form returns a json file, how can I save the file to a var in javascript?
  Thansk for helping</p>
  
  <p>Best Regards / Johnny</p>