먼저 검색했지만 수정하지 않았습니다. 여기 내 jQuery 코드입니다. 여기 Ajax get undefined 편안한 API 목록
var rootUrl = "http://" + window.location.host + "/Blog/rest/posts";
var allPosts = function() {
\t $.ajax({
\t \t type : 'GET',
\t \t url : rootUrl,
\t \t dataType : "json",
\t \t success : renderAllPosts
\t });
};
var renderAllPosts = function(data) {
\t $.each(data, function(index, post) {
\t \t alert(data); // returns [object Object]
\t \t alert(post); \t // returns [object Object],[object Object]
\t \t $('#allPosts').append(
\t \t \t \t '<a href=posts/' + post.ID + '><h3 id="animation_style">'
\t \t \t \t \t \t + post.title + '</h3></a><hr>');
\t });
}
$(document).ready(function() {
// \t alert(window.location.host);
\t allPosts();
});
를 반환하는 데이터 ... 나는 아무 생각이 왜 경고 (게시물) 두 개의 객체를 반환합니다. 나는 그것이 경고 (데이터) 두 개의 객체를 반환해야한다고 생각합니다.
나는 $ .each (data.data, function (in dex, post) 및 $ .each (data.dataList, function (index, post), 작동하지 않음) – Chase