Is ajaxComplete() guaranteed to run after any DOM updates?

147 views Asked by At

JQuery's ajaxComplete() lets me run my own Javascript after an AJAX request completes.

However, when manipulating DOM elements in an ajaxComplete() handler, I sometimes have observed strange problems, which look like the DOM changes caused by the AJAX request are not complete. In other words, it looked like there was a race condition between the DOM updates by the AJAX request and the ajaxComplete() handler.

Unfortunately, I could not find anything definite about this in the JQuery docs. Thus my question:

Is a race condition between AJAX request and handlers possible? Or does JQuery guarantee that ajaxComplete() handlers will only run after all DOM updates from the AJAX request are done?


For example, in this forum thread someone claims:

Regarding execution order. The execution order in PrimeFaces is

1) onsuccess / onerror callbacks 2) DOM update 3) oncomplete callback

Complete is a function to be called when the request finishes, after success and error callbacks were executed and DOM was updated. But keep in mind, DOM update can takes some time and not be finished in oncomplete

This seems to indicate that oncomplete callback (which is implemented using JQuery's ajaxComplete()) will run concurrently with the DOM update. Or is this a misunderstanding?

0

There are 0 answers