I have a table (I use the DataTables plugin for jQuery), and when I click on a row, I want to redirect to another page where client details will be displayed.
Here is my code in the 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 customer_details.php
<div>Company name</div>
<div>
<?php
$name = $_POST['name1'];
echo "$name";
?>
</div>
When I click on the line, they redirect me to the customer information page, but I do not see the data (i.e. the name). When I look at the response tab in the console in Firebug, I can see this data in a div.
Can someone help me what am I doing wrong?
source
share