gpt4 book ai didi

javascript - 如何使用jquery-tabledit通过javascript将变量传递给ajax?

转载 作者:行者123 更新时间:2023-11-28 07:04:25 26 4
gpt4 key购买 nike

我目前正在使用jquery插件Tabledit当我使用内联编辑(如示例 3 所示)时,它会调用我的 php 页面。我不知道如何将编辑中所做的更改传递到新的 php 页面,以便我可以在数据库中更改它。当你按回车键时它会改变。 (我猜测输入后它会调用 edittask.php)

html 这里是表格的一部分。输入新文本后按 Enter 键它会发生变化。

<td class="tabledit-view-mode"> <span class=" tabledit-span ">header text</span>
<input class="tabledit-input form-control input-sm" type="text" name="description" value=" " style="display: none;" disabled="" />
</td>

javascript

$('#thetable').Tabledit({
url: 'editTask.php',
editButton: false,
deleteButton: false,
columns: {
identifier: [0, 'id'],
editable: [
[1, 'Header'],
[2, 'Description']
]
}
});

最佳答案

根据这个sample ,在您的 php 脚本中您可以使用 POST 数组中的变量。在您的情况下:$_POST['description']$_POST['header']

我的意思是:

index.php:

<table class="table table-striped table-bordered" id="example3">
<thead>
<tr>
<th>#</th>
<th>Header</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Header 1</td>
<td>Description 1</td>
</tr>
</tbody>
</table>
<script>
$(function(){
$('#example3').Tabledit({
url: 'example.php',
editButton: false,
deleteButton: false,
hideIdentifier: true,
columns: {
identifier: [0, 'id'],
editable: [[1, 'header'], [2, 'description']]
}
});
});
</script>

示例.php:

print_r($_POST); 
// Array ( [id] => 1 [header] => Header 123 [action] => edit )
// Implement your logic here...

关于javascript - 如何使用jquery-tabledit通过javascript将变量传递给ajax?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31811135/

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