내가 이런 코드 snipet이 완료되면 제어하는 플래그 VAR를 사용하는 콜백 함수를 만들 :대신에 특정 기능이
var nbrPrevArt = $("#accordion > div .accordionPanel").size();
var processing = false;
if (nbrPrevArt == 0) {
processing = true;
getArticlesPreview();//Fetches articles first
}
//loop that makes the browser to wait until finishes "getArticlesPreview()"
while(!processing)
{
}
//getArticlesPreview() is finished now we can safely execute this step
$.ajax({
type: "GET",
url: "http://mydomain.com/somepage.htl",
success: function(data) { alert(data);}
});
//-----------------------------------
function getArticlesPreview()
{
//lenghty operation
processing = false;
}
내가 만드는 루프를 사용하고 있기 때문에 매우 실용적 보이지 않는 다음 단계를 수행하기 위해 기능이 경쟁적으로 실행될 때까지 대기합니다.
첫 번째 작업이 끝나고 두 번째 단계 ($ .ajax 호출)가 제대로 실행될 때 호출되는 콜백 메시지를 정의하는 방법이 있습니까?
미리 감사드립니다. Texeira
+1, 멋진 트릭은, 내가 당신이 적용 할 필요가 없습니다이 경우 그 – karim79