title: Save entire HTML content with both form data and HTML to server?
body: <p>I'm trying to save a page that contain a form to a server by sending AJAX with the wanted data. I wish to save the entire webpage <em>and</em> the data inserted.</p>
  
  <p>The result should be like when you locally choose  <code>File -&gt; Save as</code> in the broswer. Then inserted values are automatically transfered to the value attributes of the form.</p>
  
  <p>Good languages: jQuery, Javascript, HTML5 that is supported in the three last Firefox and Chrome versions.<br>
  Not good: Flash, Silverlight, Java etc..</p>
  
  <p>Example:</p>
  
  <pre><code>$(document).on('click', '#button_duplicate', function () {
     $.post("save_page", { data: YOUR_ANSWER });
  </code></pre>
  
  <p>Tried, but not working:</p>
  
  <ul>
  <li><code>$(":root").html()</code>: Gets only the html without inserted values.</li>
  <li><code>$(":root").value()</code> or <code>$(":root").text()</code>: No HTML elements.</li>
  <li>Localstorage solutions: I wish to save to server as a file.</li>
  <li>XPCOM and Browser depended solutions such as Firefox <code>saveDocument()</code>: I need to support both Firefox and Chrome including not the latest version.</li>
  </ul>
  
  <p>Update: I've found this library that does exactly what I need but saves to local storage, the solution is the same but to be able to save to the server side as a file: <a href="http://shaneriley.com/jquery/remember_state/" rel="nofollow">http://shaneriley.com/jquery/remember_state/</a></p>