title: using jquery.html() to save html elements to database
body: <p>I have a prooblem,which I searched a lot but couldnt find any solution,so decided to post a question.I have a webpage,which is been generated dynamically.It is required that i save whole appended body of the webpage to the database.I am using php and mysql.For saving the data I am using this:</p>
  
  <pre><code>$(function(){htmldata=$('body').html();});
  </code></pre>
  
  <p>With this I am able to store whole form along with script.
  But the problem arises,that when I start calling the value from database,html data is coming out fine,but script is all messed up.</p>
  
  <p><strong>when calling from database I am using</strong>.</p>
  
  <pre><code>$html = trim(addslashes(htmlspecialchars(
                          html_entity_decode($_POST['htmldata'], ENT_QUOTES, 'UTF-8'),
                          ENT_QUOTES, 'UTF-8'
                      )));
  </code></pre>
  
  <p>What could be possible solution for this problem.I guess this will only work for data without script.Please help.</p>
  
  <p>This is what my script looks like after calling from database</p>
  
  <pre><code>function test()
      {
          var formData = form2object(&amp;#039;testForm&amp;#039;, &amp;#039;.&amp;#039;, true,
  
                  function(node)
                  {
                      if (node.id &amp;&amp; node.id.match(/callbackTest/))
                      {
                          return { name: node.id, value: node.innerHTML };
                      }
                  });
  </code></pre>
  
  <p>Things like &#039; getting added</p>
  
  <p><strong>My original script</strong></p>
  
  <pre><code>function test()
      {
          var formData = form2object('testForm', '.', true,
  
                  function(node)
                  {
                      if (node.id &amp;&amp; node.id.match(/callbackTest/))
                      {
                          return { name: node.id, value: node.innerHTML };
                      }
                  });
  </code></pre>