When I load HTML content via AJAX onto a div using Mootools 1.11 and squeezebox, everything works perfectly in Firefox. However, when I try to load it in Internet Explorer (tested on IE7), the code fails with an error message stating "'null' is null or not an object." Upon further investigation, I discovered that the new elements loaded by AJAX are not being recognized in the IE DOM. For example, when I tried running document.getElementById('test'), it returned null for a div with id 'test' that was just loaded.
Has anyone encountered this issue before and found a solution or workaround?
Additional information: I placed my script inside the window's 'domready' event. I also attempted to use the 'load' event, but IE never triggered it.
UPDATE
After testing the script in IE8 with its improved debugging capabilities, it appears that the issue lies in the timing of the script execution. The code runs during the window's domReady event, but it executes almost immediately without waiting for the entire DOM to be ready within the popup window. When running the same script using a debugger after the page has fully loaded, the elements can be located without any problems.
Therefore, the question now becomes how to ensure that the script runs at the appropriate time.
- The domready event seems to fire before the DOM is actually ready
- The load event doesn't seem to trigger at all
- Placing the script at the end of the file, after the HTML objects, does not solve the issue either
- In the Mootools AJAX options, I have set 'evalScripts' to true; otherwise, the script doesn't run at all
Any ideas on how to address this problem?