$(".content-short").click(function() {
$(".content-full").empty();
var contentid=$(this).parent().find(".content-full").attr('data-id');
var content=$(this).parent().find(".content-full");
alert(contentid);
var collegename = $(this).attr('data-id');
$.ajax({
type: "post",
url: "contenthome.php",
data: 'collegename=' + collegename,
dataType: "text",
success: function(response) {
$content.html(response);
}
});
});
此处警报显示特定的数据 ID,但
content=$(this).parent().find(".content-full");
这不会在内容完整的 div 中显示具有特定数据 ID 的数据 代码有什么问题或者其他什么吗?
如果我使用(."content-full");查询会显示数据;而不是
$(this).parent().find(".content-full");
最佳答案
在 ajax 回调中,您使用 $content
,但将变量声明为 content
。这可能是问题所在吗?
你的问题不清楚。你想达到什么目的?
关于javascript - (this).parent().find 无法在 ajax 调用中获取响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32164795/