jQuery的不能正常工作,如果里面的AJAX后成功/失败 [英] jquery not working inside if after AJAX success/failure
问题描述
我刚开始学习AJAX 张贴之前我已经搜查,refered以previous问像<一个问题href="http://stackoverflow.com/questions/17710898/jquery-if-statement-not-working-inside-ajax-success-function">this但它并没有帮助 还有我的code是:
I have just started learning AJAX Before posting I have already searched and refered to previous asked questions like this but it didn't helped well My Code is:
$('.del').click(function(){
$(this).parent().hide('slow');
$.get( "index.php", {del:$(this).attr('id')}).done(function(data){
if (data==='1') {
$(this).parent().remove();
}
else{
$(this).parent().show('slow');
}
});
});
如果在 jQuery的声明以及
其他
不执行验证每一件事情进行的很顺利我有添加了一个警告
的声明,并弹出成功,但jQuery的语句是不是working.Whats的问题,以及如何解决这一问题?
the jquery statements inside if
as well as else
is not executed To verify every thing is going well I had added an alert
in the statements and it popped up successfully but the jquery statements isn't working.Whats The problem and how to fix this ?
推荐答案
我相信你的 $(本)
引用不正确,在该范围内。尝试:
I believe your $(this)
reference is incorrect in that scope. Try:
$('.del').click(function(){
var $this = $(this);
$this.parent().hide('slow');
$.get( "index.php", {del:$this.attr('id')}).done(function(data){
if (data==='1') {
$this.parent().remove();
}
else{
$this.parent().show('slow');
}
});
});
这篇关于jQuery的不能正常工作,如果里面的AJAX后成功/失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!