Ajax请求
发布时间:2020-12-15 21:37:02 所属栏目:百科 来源:网络整理
导读:Ajax请求 $( function () { $( '#send' ).click( function () { $.ajax({ type: "GET" ,url: "test.json" ,data: {username:$( "#username" ).val(),content:$( "#content" ).val()},dataType: "json" ,success: function (data) { $( '#resText' ).empty();
Ajax请求 $(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);
}
});
});
});
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |