취업/자바스크립트

[JS] AJAX 로딩바 사용시 async: false를 꺼줘야 한다.

카슈밀 2022. 8. 8. 15:49
반응형

ajax 사용시 유독 오래 업로드 되는 구간이 있어서 해당 부분을 처리해야했다.

그런데, 안먹힌다. 뭘해도 업로드 끝나고 작동되는 문제가 있었다.

제이쿼리 이벤트 바인딩이 느려서인가?

document.getElementById로 잡아보기도하고, 이것도 느리니 아예 함수 호출시 내장으로 변수에 할당해서 구현해보기도 하였다.

그래도 안된다...

찾다보니 async를 꺼보라네?

그렇다 ajax 내 async : false 상태가 되면 이전단계에선 호출이 안되는 것...

즉 모든 이벤트가 끝나고 작동되게 되는 것이다.(error/success/complete)

더보기

what it is saying is, if your request is async: false then you should not use ajax.done(), ajax.fail() etc methods to register the callback methods, instead you need to pass the callback methods using success/error/complete options to the ajax call

https://stackoverflow.com/questions/18267969/asyncfalse-option-not-working-in-ajax-is-it-depreciated-in-jquery-1-8-fo

 

async:false option not working in $.ajax() , is it depreciated in jQuery 1.8+ for all use cases?

I'm confused about using the async: false option with $.ajax(). According to the $.ajax() documentation: As of jQuery 1.8, the use of async: false with jqXHR ($.Deferred) is deprecated; you

stackoverflow.com

 

 

++ 이렇게 했더니 해당 ajax값이 pending상태면 기다려야 하는 부분에서 건너뛰고,

그냥 가서 빈값으로 들어가는 참사가 발생한다...

대안을 찾아봐야겠다.

728x90