我有一个函数用于创建请求到另一个文件以更新数据库:
当我点击ID为
$('#thumb-up').live('click', function() {
$('#loading').show();
$.ajax({
context: this,
type: 'GET',
url: '/gallery/configurations/required/photo-thumbs.php',
data: 'i=21&t=1',
success: function() {
$('#loading').hide();
$(this).attr('id', 'thumbup-undo').text('Sluta gilla');
$('#thumbup-count').load('/gallery/configurations/required/thumbup-count.php?i=21&t=1');
}
});
});
$('#thumbup-undo').click(function() {
alert('das');
});
当我点击ID为
thumb-up
的链接时,预期的文本会变成“Sluta gilla”。当我现在点击此链接后,相同a标签的ID将从thumb-up
更改为thumbup-undo
并显示警报“dsa”。问题在于它没有出现!我甚至不知道它是否更改为thumbup-undo
,但我希望它没有。
您可以在这里尝试代码(我已缩短了代码以使演示正常工作)。
我该如何解决这个问题?
提前致谢