當前位置:
首頁 >
【JavaScript&jQuery】$.ajax()
發(fā)布時間:2024/10/8
40
如意码农
生活随笔
收集整理的這篇文章主要介紹了
【JavaScript&jQuery】$.ajax()
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
$(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里面的所有內(nèi)容
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);
}
});
});
});
總結(jié)
以上是生活随笔為你收集整理的【JavaScript&jQuery】$.ajax()的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Pytorch中DataLoader类
- 下一篇: 二十一、JavaScript之访问对象属