get json 함수에 의해 데이터가있는 요소를 추가하는이 스크립트가 있습니다.이 get 함수가 완전히 완료되어 렌더링 된 후에 다른 함수가 실행되도록하려면 어떻게해야합니까?
$(document).ready(function() {
ADD.Listitem.get();
});
그것은 basicly 내가 가진 문제는 다음되는 등 데이터를 html 태그의 무리에 추가 :
$(document).ready(function() {
ADD.Listitem.get();
var arr = [];
$(".Listitem-section-item-title").each(function() {
arr.push($(this.text()));
});
});
- json으로 얻을 여기에
get: function(web) {
AST.Utils.JSON.get("/_vti_bin/AST/ListItem/ListitemService.svc/GetListItem", null, AST.Listitem.renderListitem);
},
renderListitem: function(data) {
$("#Listitem-template").tmpl(data["ListItemResults"]).prependTo(".ListItem-section-template");
}
을과 :
ADD.Utils.JSON.get = function (url, data, onSuccess) {
$.ajax({
type: "GET",
contentType: "application/json; charset=utf-8",
async: true,
url: url,
data: data,
cache: false,
dataType: "json",
success: onSuccess,
error: ADD.Utils.JSON.error,
converters: { "text json": ADD.Utils.JSON.deserialize }
});
}
각 루프는 ru가 아닙니다. 선택 메서드를 찾을 수 없도록 get 메서드가 Listitem-section-item-title
셀렉터 렌더링으로 끝나지 않았습니다.
좋은 해결책이 있습니까?
'get()'이 비동기식 인 경우 콜백 인수를 취하거나 약속을 반환해야합니다. 당신은 그 기능의 저자입니까? –
'get'은 비동기식입니까? 그럼 아마 콜백을 수락하거나 약속을 반환합니다 * [편집 : 젠장, 프레디 릭 빠릅니다 ... 적어도 그것은 동의합니다 :)] *. –
Ajax 코드를 $ (document) .ready() 함수에 넣은 다음 Ajax 호출의 Success 함수에 여분의 코드를 추가 할 수 있습니다. – Nunners