0
당신이 http (s) 요청을 보낼 때 함수를 만들려고합니다. 진행중인 요청이 5 개 이상인 경우 중 하나가 완료 될 때까지 기다려야 다음 요청을 처리 할 수 있습니다. 그 순수한 JS에서 할 수있는 방법이 지금까지자바 스크립트 AJAX 보류중인 요청
function makerequest ("/routeplanner/data","GET",sucess,error)
{
var xmlHttp = new XMLhttpRequest();
var count =0;
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readystate ==4 && xmlHttp.statue ==200) {
success (xmlHttp.responseText);}
else if (xmlHttp.status !=200 &&count !=3){
count++;
xmlHttp.open(method,url,true);
else if (count ==3){
error("you have reached the maximum number of tries")
}
}
xmlHttp.open("GET","/routeplanner/data",true);
xmlHttp.send(null)
}
어떤 생각을 했어요.
이 방법이 유용합니까? 첫 번째 줄은 유효한 자바 스크립트처럼 보이지 않습니다. – Ouroborus
아니요, 오류가 있습니다. –
질문에 오류를 추가하십시오. – Ouroborus