我开始在Ajax中,我有一些问题。我有一个包含一些视频缩略图的列表页面,当您翻阅它们时,会显示一个“我不喜欢这个”图标。完成了。现在我有问题是:jQuery的Ajax - 响应应取代html
当你点击该图标,视频标题,缩略图&信息应该消失,并且必须显示另一个视频。
这里是我的Ajax代码
function ThumbsDown(id,sort,page) {
$.ajax({
url: "/change/videos/"+id+"/thumbsdown/",
type: "POST",
data: {
"sort": sort?sort:"",
"page": page?page:""
},
complete: function(result) {
// Instead of calling the div name, I need to be able to target it with $(this) and .parent() to make sure only 1 video change, but for now I only want the response to replace the video
$("#content .videoList ul li.videoBox").html(result);
}
});
}
请求工作,即时通讯刚开(200 OK)响应。它将新视频的HTML代码块返回给我。
问题是,当我点击图标时,,div中的所有html都不见了。我有一个空标签,所以我想它的解释为“空”。但在我的萤火虫.Net标签中,我清楚地看到有一个回应。
请帮忙吗? 已经定型,多亏
* *编辑**
现在即时通讯有瞄准特定的分度,$(本)和父母()的问题。有人可以帮忙吗?
我要定位的李#videoBox
<li class="videoBox recommended">
<div class="spacer" style="display: block;"></div>
<div class="features">
<div>
<a class="dislike_black" title="I dislike this" onclick="ThumbsDown(30835, 'relevance', '1');"></a>
</div>
...
我想这一点,并且它不工作。
success: function(data) {
$("#content .videoList ul li.videoBox").html(data); // this IS WORKING, but replacing ALL the thumbs
$(this).parents("li.videoBox").html(data); // THIS IS NOT
我在做什么错?
非常感谢!不知道成功/完成的反应是不同的! – Lelly
我有另一个问题,请检查我的第一篇文章吗? – Lelly