我有几个表是在 reader.php 的 foreach 中生成的
<table class="object_list_<?php echo $title; ?>">
在同一个文件中有一个 jquery 调用的链接:
<a href="#" onclick="show_object('<?php echo $itemId.','.$title; ?>')"><?php echo (string)$flat.'</a><br />'; ?>
我在处理程序文件 catalogue.php 中的 jQuery 函数如下所示:
<script>
function show_object(itemid,object_type){
var request = $.ajax({
url: "show_object.php",
type: "GET",
data: "id="+ itemid,
dataType: "html"
});
$(table['.object_list_' + object_type]).hide();
request.done(function(msg) {
$(".show_object").append(msg);
});
request.fail(function(jqXHR, textStatus) {
alert( "Request failed: " + textStatus );
});
}
</script>
问题在于 hide() 函数
$(table['.object_list_' + object_type]).hide();
这不起作用。请注意,这与其他文件中object_type
的相同$title
,我通过 a href javascript 调用传递它。
我一直在stackoverflow和google上搜索,但我找不到错误。它正确加载 show_object.php,但不隐藏表格。
我也尝试了其他几个版本,例如:
$('.object_list_' + object_type).hide();
并首先在变量中添加数据,然后在隐藏函数中添加数据.. 无济于事