Ajax发送请求模版

来源:互联网 发布:刘炳森手机字体软件 编辑:程序博客网 时间:2024/06/03 23:01
$(function(){    $('#send').click(function(){         $.ajax({             type     : "POST",             url      : "",             cache    : false,             data     : {username:$("#username").val(), content:$("#content").val()},             dataType : "json",             success  : function(data){                         $('#resText').empty();                         $.each(data, function(commentIndex, comment){                               html += '<div class="comment"><h6>' + comment['username']                                         + ':</h6><p class="para"' + comment['content']                                         + '</p></div>';                         });                         $('#resText').html(html);                      },             error    : function () {                        alert("处理出错,请重新处理!");                      },            complete  : function(data) {                        alert("处理完成");                      }         });    });});


$.ajax({   type     : "POST",   url      : ctx + "",   cache    : false,   data     : {productId : productId},   dataType : "json",   success  : function(data){   },   error    : function () {   },   complete  : function(data) {   }});


0 0
原创粉丝点击