Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>As far as you're concerned once you've "pulled out" the contents with something like <a href="http://docs.jquery.com/Attributes/html" rel="noreferrer">.html()</a> it's just a string. You can test that with</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;runthis&lt;/title&gt; &lt;script type="text/javascript" language="javascript" src="jquery-1.3.2.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready( function() { var x = $("#foo").html(); alert( typeof(x) ); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="foo"&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;x&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;span&gt;xyz&lt;/span&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>The alert text is <i>string</i>. As long as you don't pass it to a parser there's no magic about it, it's a string like any other string.<br> There's nothing that hinders you from using <a href="http://docs.jquery.com/Ajax/jQuery.post" rel="noreferrer">.post()</a> to send this string back to the server.</p> <p><b>edit</b>: Don't pass a string as the parameter <i>data</i> to .post() but an object, like</p> <pre><code>var data = { id: currid, html: div_html }; $.post("http://...", data, ...); </code></pre> <p>jquery will handle the encoding of the parameters.<br> If you (for whatever reason) want to keep your string you have to encode the values with something like <a href="http://www.w3schools.com/jsref/jsref_escape.asp" rel="noreferrer">escape()</a>.</p> <pre><code>var data = 'id='+ escape(currid) +'&amp;html='+ escape(div_html); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload