Skip to content Skip to sidebar Skip to footer

Reference Errors Thrown In Included File... Unless Calling File Includes Slow Code

A funny thing happened to me while I was cleaning up some old JavaScript code this week. When I took out some slow code, the page started throwing Reference Errors on code in a fil

Solution 1:

What I observe is your alert run before document ready, and it prevents document ready until the alert dialog is closed. Fiddle: https://jsfiddle.net/24pg3yzk/

While the alert dialog is displayed, the Ajax request and its done handler $("#place").html(data); may have finished. So yes, it's race condition.

Is it standard or consistent behavior? I don't know. I think it makes sense since alert "Dialog boxes are modal windows - they prevent the user from accessing the rest of the program's interface until the dialog box is closed" (source), but nothing to affirm it from the jQuery doc.


Post a Comment for "Reference Errors Thrown In Included File... Unless Calling File Includes Slow Code"