如何使用jQuery AJAX将大型HTML标记数据传递给我的PHP?当我收到结果时,这是错误的。
jQuery AJAX代码:
$('#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实际值:
Root node 1
Child node 1
Child node 2
Root node 2
从我的show_tree div返回结果: