Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/rust/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php AJAX成功后隐藏div_Php_Ajax - Fatal编程技术网

Php AJAX成功后隐藏div

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",

我使用以下AJAX调用更新我的表中的记录:

$(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
应该是选项之一,而不是在函数内部。没有注意到,这更简单