In the following Php code I would like to access the values stored in my $val variable from my jQuery script so as to be able to send a ajax call. For each table row the $val would be containing unique values, I need to access the unique values to be able to send to my post request.
<?php
if($batch_query != null){
$i = 0;
foreach($batch_query->result_array() as $row){
$val = "'".$row['course_id'].",".$row['center_id'].",".$row['batch_id']."'";//These values are coming from the server side and I need to send it to the controller for the Ajax.
echo "<tr>";
echo "<td>".$row['course_name']."</td>";
echo "<td>".$row['center_name']."</td>";
echo "<td>".$row['batch_name']."</td>";
echo "<td>"."<button id= \"btnnumber_$i\" class='btn info toggler' value=$val>Show Info <i class='icon-arrow-down'></i></button>"."</td>";// here I am using the value attribute and assigning it the value $val.
}
}
?>
Here is my JQuery
$(function(){
$.post('/path /to/ my /controller', {value: $val}).done(function(data){
});
});
How to get those values in the $val ?
Any help will be highly appreciated.