Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.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
Jquery .html()在ajax调用后不起作用_Jquery - Fatal编程技术网

Jquery .html()在ajax调用后不起作用

Jquery .html()在ajax调用后不起作用,jquery,Jquery,我在浪费时间寻找解决方案,我找不到 这是我的密码: $(".usefull").bind("click", function(e){ e.preventDefault(); var fbkId = $(this).find(".glyphicon").data("id"); $(this).parent().html('<a href="#" class="btn btn-grey usefull disabled"><img src="/www/ima

我在浪费时间寻找解决方案,我找不到

这是我的密码:

$(".usefull").bind("click", function(e){
    e.preventDefault();
    var fbkId = $(this).find(".glyphicon").data("id");
    $(this).parent().html('<a href="#" class="btn btn-grey usefull disabled"><img src="/www/images/mini-loader.gif" alt="" /> Est utile</a>');
    var that = this;
    $.post('{{ route("www-ajax-feedback-add-usefull") }}',{ fbkId: fbkId },
            function(data) {
                if (data == '1') {
                    toastr.success('Merci pour votre contribution !');
                    $(that).parent().html('<i class="glyphicon glyphicon-thumbs-up disabled"></i> Est utile</a>');

                } else {
                    toastr.error(data);
                }
            }
    );
    return false;
});
$(.usefull”).bind(“单击”,函数(e){
e、 预防默认值();
var fbkId=$(this.find(“.glyphicon”).data(“id”);
$(this.parent().html(“”);
var=这个;
$.post({route(“www-ajax反馈添加有用”)}},{fbkId:fbkId},
功能(数据){
如果(数据='1'){
祝你成功(‘谢谢你的贡献’);
$(that.parent().html('Est-utile');
}否则{
toastr.错误(数据);
}
}
);
返回false;
});
当我点击一个按钮时,我会用加载gif更新该按钮

当ajax调用完成时,我想更新状态按钮,但它不起作用

谢谢你的帮助

以下是更多信息:

<a href="#" class="btn btn-grey agree"><i class="glyphicon glyphicon-thumbs-up" data-id="2161"></i> Je suis d'accord</a>

如果我放置console.log($(that.html());美元后,在此处发布其输出:
Je suis d'accord

对于通过ajax绑定到DOM或在运行时添加的任何元素,您必须使用

http://api.jquery.com/live/
或代表

http://api.jquery.com/delegate/

这些将在文档级别绑定。

==>
引用javascript对象,并使用jQuery进行封装

$(".usefull").bind("click", function(e){
    e.preventDefault();
    var fbkId = $(this).find(".glyphicon").data("id");
    $(this).parent().html('<a href="#" class="btn btn-grey usefull disabled"><img src="/www/images/mini-loader.gif" alt="" /> Est utile</a>');
    var that = $(this);
   // use $(this); insetd of this;

    $.post('{{ route("www-ajax-feedback-add-usefull") }}',{ fbkId: fbkId },
            function(data) {
                if (data == '1') {
                    toastr.success('Merci pour votre contribution !');
                    $(that).parent().html('<i class="glyphicon glyphicon-thumbs-up disabled"></i> Est utile</a>');

                } else {
                    toastr.error(data);
                }
            }
    );
    return false;
});
$(.usefull”).bind(“单击”,函数(e){
e、 预防默认值();
var fbkId=$(this.find(“.glyphicon”).data(“id”);
$(this.parent().html(“”);
var,该值=$(此值);
//使用$(此);插入此项;
$.post({route(“www-ajax反馈添加有用”)}},{fbkId:fbkId},
功能(数据){
如果(数据='1'){
祝你成功(‘谢谢你的贡献’);
$(that.parent().html('Est-utile');
}否则{
toastr.错误(数据);
}
}
);
返回false;
});
阅读更多

什么是“那”$(that).parent().html(…),是否为“this”?似乎您的html在
html()
call中不正确…我只是按照您的建议进行替换,仍然存在相同的问题您是否确定您的ajax功能已成功完成请检查浏览器控制台是否有任何错误是的,已完成,我看到消息trought toastr并且没有错误,我会说它仍然不工作,但我在控制台中没有错误。我尝试使用$(“.usefull”)。在(“单击”,函数(){(live被折旧,“delegate”和“on”相同)。它不工作尝试使用
。完成(函数(){
看看它是否进入该块,参考:感谢您的建议,是的,它进入了,但是$(this.parent().html仍然不起作用