jquery hide div 在成功回调后不起作用
我希望有人能指出为什么我的 div (在我的例子中,我使用 li)在成功执行我的 php 脚本后没有使用 jquery 隐藏。
这是我的查询代码(来自 jquery impromptu 插件):
if(v){
var bid = f.bannerid;
$.post('/manage/<?=CFILE?>',{bannerid:f.bannerid,action:'deleteBanner',cid:<?=$contentid?>,uid:'<?=$_SESSION['userid']?>'},{callback:function(data){
if(data=='true'){
$('#list_'+bid).hide('slow', function(){ $(this).remove(); });
}else{
$.prompt('An Error Occured while removing this banner');
}
}});
}
这是我的 html 代码的一部分:
<li id="list_47">
<div>
<div id="row">
<div class="title id="bannerid59"><img src="banner_45_10.jpg" /></div>
<div class="action"><a href="javascript:;" title="Delete Banner" class="deleteBanner" onclick="deleteBanner(59);">Delete</a></div>
</div>
<div id="row-right">
<span class="small">Sort Order: 2</span><br>
</div>
</div>
</li>
<li id="list_48">
<div>
<div id="row">
<div class="title id="bannerid60"><img src="banner_45_11.jpg" /></div>
<div class="action"><a href="javascript:;" title="Delete Banner" class="deleteBanner" onclick="deleteBanner(60);">Delete</a></div>
</div>
<div id="row-right">
<span class="small">Sort Order: 3</span><br>
</div>
</div>
</li>
最后,这是我的简单 php 代码:
if(isset($_POST['action']) && $_POST['action']=="deleteBanner"){
mysql_query("DELETE FROM banner where banner_image='".$_POST['bid']."' AND users_id='".$_POST['uid']."'") or die(mysql_error());
print "true";
exit;
}
我可以使用这些代码从 mySQL 数据库中删除我的横幅,没有任何问题,但我不能似乎在脚本执行时隐藏了已删除的 li(例如 list_47)。
任何帮助表示赞赏。 谢谢。
I was hoping someone can point out why my div (in my case, I use li) isn't hiding using jquery upon successful execution of my php script.
Here is my query code (from jquery impromptu plugin):
if(v){
var bid = f.bannerid;
$.post('/manage/<?=CFILE?>',{bannerid:f.bannerid,action:'deleteBanner',cid:<?=$contentid?>,uid:'<?=$_SESSION['userid']?>'},{callback:function(data){
if(data=='true'){
$('#list_'+bid).hide('slow', function(){ $(this).remove(); });
}else{
$.prompt('An Error Occured while removing this banner');
}
}});
}
here is part of my html code:
<li id="list_47">
<div>
<div id="row">
<div class="title id="bannerid59"><img src="banner_45_10.jpg" /></div>
<div class="action"><a href="javascript:;" title="Delete Banner" class="deleteBanner" onclick="deleteBanner(59);">Delete</a></div>
</div>
<div id="row-right">
<span class="small">Sort Order: 2</span><br>
</div>
</div>
</li>
<li id="list_48">
<div>
<div id="row">
<div class="title id="bannerid60"><img src="banner_45_11.jpg" /></div>
<div class="action"><a href="javascript:;" title="Delete Banner" class="deleteBanner" onclick="deleteBanner(60);">Delete</a></div>
</div>
<div id="row-right">
<span class="small">Sort Order: 3</span><br>
</div>
</div>
</li>
Finally, here is my simple php code:
if(isset($_POST['action']) && $_POST['action']=="deleteBanner"){
mysql_query("DELETE FROM banner where banner_image='".$_POST['bid']."' AND users_id='".$_POST['uid']."'") or die(mysql_error());
print "true";
exit;
}
I am able to delete my banner from mySQL database without any problem using these codes but i can't seem to hide the deleted li (for example, list_47) upon script execution.
Any help is appreciated.
thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您没有正确调用
$.post
,您的{callback: function() ... }
应该只是函数:$.post
将在其参数列表中查找函数,但找不到;由于没有传递回调函数,因此不会调用任何回调,并且您的不会被隐藏。
比较这两个:
{callback:function() {/*...*/} }
但它不起作用。You're not calling
$.post
correctly, your{callback: function() ... }
is supposed to be just the function:$.post
will look for a function in its argument list but won't find one; since there is no callback function passed, no callback will be called and your<div>
won't be hidden.Compare these two:
{callback:function() {/*...*/} }
and it doesn't work.