My head hurts from bashing it against the wall during the past few days.
In a nutshell, here is my problem: I have a select element that has a function attached via onchange. The function does some AJAX using the HTML_AJAX library.
When I use Firefox, if I select an item in the list, then the code executes in a timely manner, which means that I see lines 1 and 2 of my debugging output (displayed at the end of this posting). The code then displays a wait window. A second or so later, I see the third and final line of debugging output when the AJAX call has completed. The wait window then disappears. Yaay!
However (and you knew that this was coming even without the "IE" tag in the subject header, didn't you?), with Internet Explorer, I see no debug output nor wait window until AFTER the AJAX call has completed one second or so later. Suddenly, every line of debug output is displayed and the code is executed. Boo!
"Hold on! Are you saying that your Javascript code isn't being executed until after the AJAX call?"
This is what I am seeing with Internet Explorer! Even if I insert an alert() message in the code, I do not see it until AFTER the AJAX call has completed, even though it appears in the code before the AJAX call. Then, I see my alert() message. I do not see the wait window because it is displayed and immediately closed during the rush of code that executes after the AJAX call has completed. The whole idea of the wait window is to display while the AJAX call is working.
Here is the code for the select element:
HTML Code:
<select id="txtfieldNbNights" tabindex="4"
onblur="return ValidNbNights(this, 4, true);"
onchange="return OnNbNightsChanged(this);"><?php code to list the OPTION elements ?></select>
Here is the definition of the OnNbNightsChanged function with my debugging code intact:
Code:
function OnNbNightsChanged(objtxtfieldNbNights)
{
var d = new Date(),
min = d.getMinutes(),
sec = d.getSeconds(),
msec = d.getMilliseconds();
addGMQ('function OnNbNightsChanged = '+min+':'+sec+'.'+msec+'\n');
try {
var ret = false;
if (objtxtfieldNbNights != null) {
var nbNights = parseInt(objtxtfieldNbNights.value, 10),
tempCkOutDate = g_ckInDate.AddDays(nbNights);
ret = IsCkOutDateValide(tempCkOutDate);
if (ret) {
UpdateCkOutDateFields(tempCkOutDate);
d = new Date();
min = d.getMinutes();
sec = d.getSeconds();
msec = d.getMilliseconds();
addGMQ(' BEFORE GetAvailRoomTypes = '+min+':'+sec+'.'+msec+'\n');
GetAvailRoomTypes(); // Does some AJAX stuff.
d = new Date();
min = d.getMinutes();
sec = d.getSeconds();
msec = d.getMilliseconds();
addGMQ(' AFTER GetAvailRoomTypes = '+min+':'+sec+'.'+msec+'\n');
UpdatePackageDisplay(g_packageDescription, g_outErrorCode, g_numberNights);
ret = true;
}
}
return ret;
} catch (e) {
// TODO: handle exception
return false;
}
}//fin du function OnNbNightsChanged(objtxtfieldNbNights)
Here is sample debug output. Note that the trailing time at the end of each line is merely the minutes, seconds and milliseconds of the current time. I do not bother displaying the hour portion.
function OnNbNightsChanged = 24:46.423
BEFORE GetAvailRoomTypes = 24:46.571
AFTER GetAvailRoomTypes = 24:47.505
Thank you for any help or clues that you can provide.
Bookmarks