I have a table (I'm using DataTables plug-in for jQuery) and when I click on a row I want to be redirected to another page where will be displayed customer details.
Here is my code in customers.php file:
<script>
$(document).ready(function () {
$('#customer').DataTable({
serverSide: true,
ajax: "customer-data.php",
scrollY: 350,
scrollX: true,
deferRender: true,
select:true,
scroller: {
loadingIndicator: true,
displayBuffer: 4,
serverWait: 100
}
});
var table = $('#customer').DataTable();
$('body').on('click', '#customer tbody tr', function () {
var name = table.cell('.selected', 1).data();
$.ajax({
type: "POST",
url: "customer_details.php",
data: {name1: name},
success: function() {
window.location = "customer_details.php";
}
});
});
});
</script>
This is in customer_details.php file
<div>Company name</div>
<div>
<?php
$name = $_POST['name1'];
echo "$name";
?>
</div>
When I click on a row I am redirected to customer details page but I can't see the data (i.e. name). When I look at response tab in console in Firebug I can see this data in div.
Could anyone help me what am I doing wrong?