$(function(){

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

         $.ajax({

             type: "GET",

             url: "test.json",

             data: {username:$("#username").val(), content:$("#content").val()},

             dataType: "json",

             success: function(data){

                         $('#resText').empty();   //清空resText里面的所有内容

                         var html = '';

                         $.each(data, function(commentIndex, comment){

                               html += '<div class="comment"><h6>' + comment['username']

                                         + ':</h6><p class="para"' + comment['content']

                                         + '</p></div>';

                         });

                         $('#resText').html(html);

                      }

         });

    });

});

相关文章:

  • 2022-01-23
  • 2022-01-08
  • 2021-06-11
  • 2022-02-11
  • 2021-12-29
  • 2022-12-23
猜你喜欢
  • 2021-11-21
  • 2021-05-23
  • 2022-02-13
  • 2021-09-01
  • 2021-11-17
  • 2022-01-19
相关资源
相似解决方案