I have this code but it does not work for me, it does not update, I want to update a div in another div but I do not know how you can help me:
<!doctype html>
<html>
<head>
<title>Document Title</title>
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script>
$('.clickable').on('click', function(){
var data_id = $(this).data('id');
$.ajax({
url: 'ajax.php',
type: 'POST',
data: {id: data_id},
success: function(data){
$('#more-info').html(data.html);
},
error: function(jqXHR, textStatus, errorThrown){
$('#more-info').html('');
alert('Error Loading');
}
});
});
});
</script>
</head>
<body>
<div id="item-one" class="clickable" data-id="123">Click me</div>
<div id="item-two" class="clickable" data-id="456">Click me</div>
<div id="more-info"></div>
</body>
</html>
code PHP:
<?php
$id = $_POST['id'];
echo $id;
?>