これを使用して次の関数を作成しました。Htmlでajax応答を表示しています
function loadData() {
$.ajax({
type: "post",
url: "http://127.0.0.1/get_scroll_rec/",
cache: false,
data:'',
success: function(response){
var obj = JSON.parse(response);
try{
var str = '';
var items=[];
$.each(obj[0], function(i,val){
//Here display code
items.push($('<div id="recent">').html(val.Title));
items.push($('<h1>').html(val.name));
items.push($('<p>').html(val.desciption));
items.push($('<div id="recent_created" class="recent_created">').html(val.added_on));
});
$('#recent_rightwrapper1').fadeOut('slow', function() {
$(this).append(str).fadeIn('slow').fadeIn(3000);
$('#recent_rightwrapper1').css({backgroundColor: ''});
$('#recent_rightwrapper1').append.apply($('#recent_rightwrapper1'), items);
}).css({backgroundColor: ''});
}catch(e) {
alert('Exception while request..');
}
},
error: function(){
alert('Error while request..');
}
});
}
});
この表示領域コードに HTMl タグを追加するにはどうすればよいですか (1 行目に変更 "h1" タグを追加、2 行目に変更 "a" タグを追加)、最後の行 5 にデータなしで div を追加したい.
1> items.push($('<div id="recent"><h1>').html(val.Title));
2> items.push($('<h1><a href="" target="_blank">').html(val.name));
3> items.push($('<p>').html(val.desciption));
4> items.push($('<div id="recent_created" class="recent_created">').html(val.added_on));
5> items.push($('<div id="blank">')