$.ajax处理数据

$(function(){
$(’#send’).click(function(){
KaTeX parse error: Expected '}', got 'EOF' at end of input: …ata: {username:("#username").val(), content:$("#content").val()},
dataType: “json”,
success: function(data){
$(’#resText’).empty(); //清空resText里面的所有内容
var html = ‘’;
$.each(data, function(commentIndex, comment){
html += ‘

’ + comment[‘username’]
+ ‘:
<p class=“para”’ + comment[‘content’]
+ ‘

’;
});
KaTeX parse error: Expected 'EOF', got '#' at position 3: ('#̲resText').html(….each()函数:
$.each()函数不同于JQuery对象的each()方法,它是一个全局函数,不操作JQuery对象,而是以一个数组或者对象作为第1个参数,以一个回调函数作为第2个参数。回调函数拥有两个参数:第1个为对象的成员或数组的索引,第2个为对应变量或内容。

猜你喜欢

转载自blog.csdn.net/aas15/article/details/82785821