问题描述
我有一个显示是在某人的车中的项目一个简单的购物车页面,并让它通过ASP,而从我的表显示。我有一个列在这里,用户可以删除条目。我有ASP的正常工作,现在我想添加一些AJAX到它。我有以下的code:
I have a simple cart page that displays items that are in someones cart, and having it display via an ASP while from my table. I have a column where a user can delete an entry. I have the ASP working properly, now I am trying to add some AJAX in to it. I have the following code:
$("img.delete").click(function() {
var id = $('#id').attr('value');
$.ajax({
type: "POST",
url: "delete.php",
data: "id="+ id,
success: function(){
$('tr.selector').remove();
$('div.success').fadeIn();
}
});
return false;
});
关键是,如何wouild我去设置它为每个值,因为如果我使用上面,我点击一个,他们都会去。我很困惑如何设置它与众多行工作。
The thing is, how wouild I go about setting it up for each value, because if I use the above, I click one and they will all go. I am confused on how to set it up to work with numerous rows.
推荐答案
您需要拆卸只选择该项目的行。我不知道你怎么把它设置,但如果图像元素是行内,你可以使用:
You need to select only the item's row for removal. I'm not sure how you have it set up, but if the image element is inside the row you could use:
$("img.delete").click(function() {
var row = $(this).parents('tr:first');
...
success: function(){
$(row).remove(); //Remove the row containing the image element
...
}
...
});
这篇关于AJAX删除 - 使用jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!