在下面的 PHP 代码中,我想从我的 jQuery 脚本访问存储在我的 $val 变量中的值,以便能够发送一个 ajax 调用。对于每个表行,$val 将包含唯一值,我需要访问唯一值才能发送到我的发布请求。
<?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.
}
}
?>
这是我的 jQuery
$(function(){
$.post('/path /to/ my /controller', {value: $val}).done(function(data){
});
});
How to get those values in the $val ?
任何帮助将不胜感激。