gpt4 book ai didi

php - jQuery/AJAX 不使用 Varchar ID 更新记录

转载 作者:行者123 更新时间:2023-11-30 21:36:24 26 4
gpt4 key购买 nike

当 idInquiryItems 是一个数字 (1) 时,此函数工作正常,但当 idInquiryItems 包含字母 (a3hcu45vn) 时,该函数不起作用。当 ID 包含字母时,它甚至不会触发确认弹出窗口。

function deleteRecord(idInquiryItems) {
if(confirm("Are you sure you want to delete this line item?")) {
$.ajax({
url: "php/delete.php",
type: "POST",
data: "idInquiryItems=" + idInquiryItems,
success: function(data){
$("#table-row-"+idInquiryItems).remove();
}
});
}

idInquiryItems 触发 Uncaught ReferenceError: a3hcu45vn is not defined 在 HTMLAnchorElement.onclick (inquiry.php?idInquiry=1:156)

HTML

<table id="inquiry-item-grid" class="w3-table w3-bordered w3-border w3-white">
<col width="50">
<col width="50">
<col width="50">

<thead>
<tr>
<th>Line</th>
<th>Qty</th>
<th>UOM</th>
<th>Description</th>
<th></th>
</tr>
</thead>
<tbody id="table-body">

<tr class="table-row" id="table-row-a3hcu45vn">
<td contenteditable="true" id="Line" onBlur="saveToDatabase(this,'Line','a3hcu45vn')" onClick="editRow(this);">1</td>
<td contenteditable="true" id="Quantity" onBlur="saveToDatabase(this,'Quantity','a3hcu45vn')" onClick="editRow(this);">1</td>
<td contenteditable="true" id="UOM" onBlur="saveToDatabase(this,'UOM','a3hcu45vn')" onClick="editRow(this);">ea</td>
<td contenteditable="true" id="Description" onBlur="saveToDatabase(this,'Description','a3hcu45vn')" onClick="editRow(this);">test</td>
<td><a class="ajax-action-links w3-right" style="padding-right: 16px; cursor: pointer;" onclick="deleteRecord(a3hcu45vn);" title="Delete a3hcu45vn">X</a></td>
</tr>
<tr class="table-row" id="table-row-1">
<td contenteditable="true" id="Line" onBlur="saveToDatabase(this,'Line','1')" onClick="editRow(this);">5</td>
<td contenteditable="true" id="Quantity" onBlur="saveToDatabase(this,'Quantity','1')" onClick="editRow(this);">1</td>
<td contenteditable="true" id="UOM" onBlur="saveToDatabase(this,'UOM','1')" onClick="editRow(this);">ea</td>
<td contenteditable="true" id="Description" onBlur="saveToDatabase(this,'Description','1')" onClick="editRow(this);">readreadread</td>
<td><a class="ajax-action-links w3-right" style="padding-right: 16px; cursor: pointer;" onclick="deleteRecord(1);" title="Delete 1">X</a></td>
</tr>

</tbody>
</table>

PHP

    <?php
require_once("config.php");
$pdo_statement=$pdo_conn->prepare("UPDATE InquiryItems SET Deleted = 1 WHERE idInquiryItems = '" . $_POST['idInquiryItems'] . "'");
$pdo_statement->execute();
?>

最佳答案

尝试

过程数据:假的,数据:“idInquiryItems =”+ idInquiryItems,

或者

数据:{idInquiryItems: id查询项

关于php - jQuery/AJAX 不使用 Varchar ID 更新记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53685041/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com