重新尝试列下的初始值将为空白。在我们选中某些行的复选框并点击按钮重新尝试后,我想更新column reattempt
的值以重新尝试。
HTML
<button id="reattempt">reattempt</button>
<tr>
<th class="table-header">Reattempt</th>
</tr>
<tr>
<td id="<?php echo $orderrecords[$k]["tracking_id"];?>reattempt">
<?php echo $orderrecords[$k]["reattempt"]; ?>
</td>
</tr>
脚本
$('#reattempt').click(function() {
var selected = [];
$('.assigneeid-order:checked').each(function() {
selected.push($(this).val());
$('.assigneeid-order').prop('checked', false);
});
var jsonString = JSON.stringify(selected);
$.ajax({
type: 'POST',
url: 'reattempt.php',
data: { data: jsonString },
success: function(response) {
response = $.parseJSON(response);
$.each(response, function(index, val) {
$('#' + index + '').html(val);
$('#' + index + 'reattempt').html(val.reattempt);
});
}
});
});
reattempt.php
$data = json_decode(stripslashes($_POST['data']));
foreach($data as $id)
{
$orderid = $id;
$reattempt='';
$sqlecom = "UPDATE do_order set reattempt = '$reattempt' where tracking_id=".$orderid;
$db_handleecom = new DBController();
$resultecom = $db_handleecom->executeUpdate($sqlecom);
$response[$orderid] = [ 'reattempt' => $reattempt ];
}
echo json_encode($response);
结果
值未更新,下面是回复:
答案 0 :(得分:1)
您要设置所有复选框以取消选中$('.assigneeid-order').prop('checked', false);
,请使用$(this).prop('checked', false);
进行编辑,这将指向循环中的当前复选框。另外,用缺少的TD更新你的html
您的代码中没有任何内容正在更新,因为在您的php文件中,您正在设置$reattempt='';
而没有任何进一步的更改,您将其返回为空..所以,您不能指望除了空值..