Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/286.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.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 jquery每个函数在$.ajax()中都不起作用_Php_Jquery_Ajax_Load_Each - Fatal编程技术网

Php jquery每个函数在$.ajax()中都不起作用

Php jquery每个函数在$.ajax()中都不起作用,php,jquery,ajax,load,each,Php,Jquery,Ajax,Load,Each,我在一个页面上有一个评论文字,里面有一个主要问题和他们的答案,就像层叠流动一样。 每个答案都有一个注释脚本。在加载问题页面时,每个答案都会加载带有以下代码的注释 $(document).ready(function(){ $('.disagree_comments').each(function(){ $(this).load("includes/disagree_comments_loader.php?aid="+$(this).parents('.answer_text')

我在一个页面上有一个评论文字,里面有一个主要问题和他们的答案,就像层叠流动一样。 每个答案都有一个注释脚本。在加载问题页面时,每个答案都会加载带有以下代码的注释

$(document).ready(function(){

    $('.disagree_comments').each(function(){
    $(this).load("includes/disagree_comments_loader.php?aid="+$(this).parents('.answer_text').children('.agree_disagree_main_cont').children('#answer_id').val());
   });
});
但是当我在ajax成功上做同样的事情时,它不起作用,我是做错了什么,还是有不同的方法来做这件事

 $('#comment_save').click(function(){

    $.ajax({
        type: 'POST', 
        url: 'includes/reply_editor.php', 
        data: "comment="+$('#comment_text_update').val()+"&id="+$('#commentid_edit').val(),
        success: function(){
            $('#comment_text_update').val('');
            $('#commentid_edit').val('');
            $('.comment_edit_transparent_layer').css('display','none');


                $('.disagree_comments').each(function(){
                    $(this).load("includes/disagree_comments_loader.php?aid="+$(this).parents('.answer_text').children('.agree_disagree_main_cont').children('#answer_id').val());
                });

        }
    });


});
应该是

data: {comment:$('#comment_text_update').val(),id:$('#commentid_edit').val()},
针对错误的div$(.不同意\评论)正确的是$('回答\同意\不同意\评论')

修改代码:

$('#comment_save').click(function(){

$.ajax({
    type: 'POST', 
    url: 'includes/reply_editor.php', 
    data: "comment="+$('#comment_text_update').val()+"&id="+$('#commentid_edit').val(),
    success: function(){
        $('#comment_text_update').val('');
        $('#commentid_edit').val('');
        $('.comment_edit_transparent_layer').css('display','none');


           $('.answer_agree_disagree_review').each(function(){
                        $(this).load("includes/answer_reply_loader.php?aid="+$(this).parents('.answer_text').children('.agree_disagree_main_cont').children('#answer_id').val());
                });
            });

    }
});


});

你说不工作是什么意思?被调用的成功方法事实上,
\answer\u id
在你的
中。每个(
循环让我觉得有不止一个元素的
id
answer\u id
,对吗?如果是这样,那就是你的问题。当我使用#comment#编辑注释时,保存它保存注释,但不再次加载它与each()一起加载的所有注释function@Blender-嗯,可能是这个问题,让我检查一下数据是否正常保存,不正常的是每个函数。它不会再次加载每个.disagree\u comments元素的注释。
$('#comment_save').click(function(){

$.ajax({
    type: 'POST', 
    url: 'includes/reply_editor.php', 
    data: "comment="+$('#comment_text_update').val()+"&id="+$('#commentid_edit').val(),
    success: function(){
        $('#comment_text_update').val('');
        $('#commentid_edit').val('');
        $('.comment_edit_transparent_layer').css('display','none');


           $('.answer_agree_disagree_review').each(function(){
                        $(this).load("includes/answer_reply_loader.php?aid="+$(this).parents('.answer_text').children('.agree_disagree_main_cont').children('#answer_id').val());
                });
            });

    }
});


});