码迷,mamicode.com
首页 > Web开发 > 详细

AJAX的最小单元

时间:2016-01-22 14:17:19      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:

$(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);

                      }

         });

    });

});

AJAX的最小单元

标签:

原文地址:http://www.cnblogs.com/handongyu/p/5150824.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!