Post html code to PHP using jQuery <p>I allow users to edit webpages using CKEditor and then save their modified HTML snippets to the server so that I can show them on subsequent page deliveries. </p> <p>I'm using this code to send the HTML and a few IDs to the server:</p> <pre><code>var datatosend = JSON.stringify( { page: 1, block: 22, content: editor1.getData() } ); $.ajax({ url: "/ajax/fragment/", type: "POST", dataType: 'json', data: "data=" + datatosend, success: function (html) { }, error: function (xhr, status, msg) { alert( status + " " + msg ); } }); </code></pre> <p>And on the server side I am using PHP and am doing this:</p> <pre><code> $json = stripslashes( $_POST[ "data" ] ); $values = json_decode( $json, true ); </code></pre> <p>This works a lot of the time when non-HTML snippets are sent but does not work when something like this is sent in the content:</p> <pre><code>&lt;img alt="" src="http://one.localbiz.net/uploads/1/Dido-3_2.JPG" style="width: 173px; height: 130px;" /&gt; </code></pre> <p>I'm really not sure what I am supposed to be doing in terms of encoding the data client-side and then decoding server-side? Also not sure if dataType: 'json' is the best thing to use here?</p>