Php AJAX成功后隐藏div
我使用以下AJAX调用更新我的表中的记录:Php AJAX成功后隐藏div,php,ajax,Php,Ajax,我使用以下AJAX调用更新我的表中的记录: $(function() { $(".decline").click(function(){ var element = $(this); var del_id = element.attr("id1"); var order_id = element.attr("data-order1"); $.ajax({ type: "POST",
$(function() {
$(".decline").click(function(){
var element = $(this);
var del_id = element.attr("id1");
var order_id = element.attr("data-order1");
$.ajax({
type: "POST",
url: "decline.php",
data: {id1:del_id,order_id1:order_id},
success: function(){cache: false}
});
$(this).parents(".show").animate({ backgroundColor: "#003" }, "slow")
.animate({ opacity: "hide" }, "slow");
});
});
当zi单击选择器类时,它会根据需要设置div的动画。在此处拒绝:
<div class="<?php echo ($accept == '1')?'showop':'show';?>">
<span class="growthcust">$<?php echo number_format($growth); ?></span>
<span class="accepted"><a href="#" class="accept" id="<?php echo $id1; ?>" data-order="<?php echo $name; ?>"><input type="button" title="accept" value="Accept" /></a></span>
<span><a href="#" class="decline" id1="<?php echo $id1; ?>" data-order1="<?php echo $name; ?>"><input type="button" title="declined" value="Decline" /></a></span>
</div>
在success
回调中运行隐藏代码。您可以使用绑定的元素
变量访问当前元素
$(function() {
$(".decline").click(function(){
var element = $(this);
var del_id = element.attr("id1");
var order_id = element.attr("data-order1");
$.ajax({
type: "POST",
url: "decline.php",
data: {id1:del_id,order_id1:order_id},
// cache: false, // Not needed for POST, they're never cached
success: function(){
element.parents(".show").animate({ backgroundColor: "#003" }, "slow")
.animate({ opacity: "hide" }, "slow");
}
});
});
});
function(){cache:false}
是函数定义的无效语法cache:false
应该是选项之一,而不是在函数内部。没有注意到,这更简单