我有一个生成的表格,当按下第 6 列上的按钮以获取行中的第一个单元格值并将其发送到覆盖页面时,覆盖页面将进行一些计算,这将需要一些时间并显示分数,我想用该分数替换第 6 列按钮。
处理时我无法让 page2.php 在叠加层中显示(我使用此处的弹出窗口)
这是我到目前为止所达到的
<tbody>
<?php foreach ($rows as $row_number => $columns): ?>
<?php
$row_class = 'row-' . ($row_number + 1);
if ($row_number == 0) {
$row_class .= ' row-first';
}
if (count($rows) == ($row_number + 1)) {
$row_class .= ' row-last';
}
?>
<tr class="<?php print $row_class; ?>">
<?php foreach ($columns as $column_number => $item): ?>
<td class="<?php print 'col-'. ($column_number + 1); ?>" >
<?php print $item; ?>
</td>
<?php endforeach; ?>
<td>
<?php print $dnsearch; ?>
</td>
<td>
<button id="my-button">Get Score</button>
<div id="element_to_pop_up">
<a class="bClose">x<a/>
这里应该 page2.php 从脚本接收变量并进行处理并返回数据(分数)以替换单击的按钮
</div>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<script type="text/javascript">
$(":button").click(function (e) {
e.preventDefault();
$('#element_to_pop_up').bPopup();
$.post("page2.php", {val: $(this).closest('tr').find('td:eq(0)').text()}, function(returned_data){
// alert(returned_data);
$(e.target).closest("td").text(returned_data); // to replace button with score
});
});
</script>