How can I pass a large HTML tag data to my PHP using jQuery AJAX? When I'm receiving the result it is wrong.
jQuery AJAX code:
$('#saveButton').click(function() {
// do AJAX and store tree structure to a PHP array
//(to be saved later in database)
var treeInnerHTML = $("#demo_1").html();
alert(treeInnerHTML);
var ajax_url = 'ajax_process.php';
var params = 'tree_contents=' + treeInnerHTML;
$.ajax({
type: 'POST',
url: ajax_url,
data: params,
success: function(data) {
$("#show_tree").html(data);
},
error: function(req, status, error) { }
});
});
treeInnerHTML actual value:
<ul class="ltr">
<li id="phtml_1" class="open">
<a href="#"><ins> </ins>Root node 1</a>
<ul>
<li class="leaf" id="phtml_2">
<a href="#"><ins> </ins>Child node 1</a>
</li>
<li class="last leaf" id="phtml_3">
<a href="#"><ins> </ins>Child node 2</a>
</li>
</ul>
</li>
<li id="phtml_5" class="file last leaf">
<a href="#"><ins> </ins>Root node 2</a>
</li>
</ul>
Returned result from my show_tree div:
<ul class="\"ltr\"">
<li id="\"phtml_1\"" class="\"open\"">
<a href="%5C%22#%5C%22"><ins></ins></a>
</li>
</ul>