【发布时间】:2013-03-25 15:21:54
【问题描述】:
所以我正在学习 JQuery,但我一直坚持:
我有一个显示 HTML 表格的页面,在该表格内我想要一个可以通过下拉菜单更新的单元格,因此您单击编辑,当前值消失并出现下拉菜单,当值更改数据库将更新并显示新值。 (菜单消失)
问题似乎在于将 .text 和 .show 放在数据回调函数中 - 如果我提醒数据它正在从 PHP 文件返回正确的数据,并且如果我注释掉 .post 行并替换 ( data) 和 ("test_text") 它替换了我想要的菜单。
希望我的问题写得足够好,能说得通,谢谢。
这是代码
$('.cat_color_hide_rep').hide();
$('.act_status_dropD').click(function () {
var record_id = $(this).parents('tr').find('.record_id').text()
$(this).parents('tr').find('.cat_color_hide_rep').show();
$(this).parents('tr').find('.cat_color_show_rep').hide();
});
$('.cat_color_hide_rep').change(function () {
var record_id = $(this).parents('tr').find('.record_id').text()
$(this).parents('tr').find('.cat_color_hide_rep').hide();
$.post('TEST_ajax_rep_list_status.php', {
ID: record_id
}, function (data) {
$(this).parents('tr').find('.cat_color_show_rep').text(data);
$(this).parents('tr').find('.cat_color_show_rep').show();
alert(data); // for testing
});
});
【问题讨论】:
-
警报的输出是什么?顺便说一句,您可以使用 javascript 控制台
console.log('value') -
警报只是来自 PHP 页面的值,以确保 .post 正常工作
-
所以更新后无法在列中显示任何内容.. ?