처음으로 나쁜 영어로 죄송합니다. 이미 그래서 검색했습니다. 하지만 나는 정확한 대답을 얻지 못했습니다. 제 문제는 Ajax 요청을 동기화해야합니다. "asynch : false"을 사용할 수 있다는 것을 알고 있습니다. 하지만 브라우저를 잠글 것입니다. 나는 폴더 트리 (나는 "tafel 트리"js)를 사용하고있다. 트리 노드는 런타임에 생성됩니다. 사용자가 노드를 클릭 할 때마다 서버에 요청을 보내 트리에 노드를 추가합니다. 페이지가 f5을 클릭하여 새로 고친 경우 문제가 발생합니다. 그런 다음 이전에 이미 선택한 트리 구조를로드해야합니다. "asynch : false"을 사용하여 구현했습니다. 하지만 브라우저가 너무 느려집니다. 사용자가 긴 지점을 열 경우 내가비동기식 AJAX 호출 방식
function loadPage() {
/* some other codes are here*/
/* here i call an ajax for get the inside folder list in correct order.(i am usig protoype)*/
new Ajax.Request(ajaxGetInsideFolderIdsUrl,
{
parameters: {branchId: CurrentSelectfolderId},
onSuccess: function(res) {
/* onSuccess i call another function*/
var brs = res.responseText.split(","); // branch ids in correct order.
syncFolder(brs)
}
}
function syncFolder(brs){
for(var i= 0 ; i < brs.length; i ++){
var tempbranch = tree.getBranchById(brs[i].getId());
selectAfterChange(tempbranch)
/*
selectAfterChange function is used for selecting current branch. calling "tafle tree" select() function in side it.
i just created an copy of "select()","_openPopulate()" functions used in "tafle tree" and modified it with "asynch : false ".and now its working fine.
*/
}
}
function selectAfterChange(brs){
brs.chk_select();
/* for selecting the branch (created a copy of current "select()" function used in "tafle tree" js
and modified it with "asynch : false "and now its working fine.) */
showList();// for listing items in side that folder (in another Ajax page).
}
내 문제가 무엇인지
여기입니다. 그리고 Ajax 호출을 동기화하기 위해 페이지를 새로 고치면로드하는 데 너무 많은 시간이 걸립니다. 시간을 너무 많이 사용하는 것이 큰 문제는 아닙니다. 브라우저는 모든 요청이 실행될 때까지 잠금 상태가됩니다. 이 작업을 수행 할 수있는 다른 방법이 있습니다.
것은 어느 당신이 한 번에 여러 노드를 반환 할 수있는 로컬 스토리지 작업 또는 백엔드 작업을 할 필요가 ... 더 비동기 요청과 나무의 나머지 부분에서 충전을 시작할 수 있습니다 . – epascarello