Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

DB Query in IE vs. Firefox

Hi Folks,

I've encountered a problem where I can run sequential calls to my database in FF and have the expected result. I've got a Country drop-down menu which, depending on the country the user selects a Province/State drop-down menu will be appropriately updated.

In FF this works well. In IE it does not. It will make the initial query but it won't perform subsequent queries. One person I worked with suggests that perhaps these things are cached and I'd have to clear the cache programatically.

The question of course is can anyone suggest to me a way to get this working in IE?

Thanks!
[649 byte] By [canadiancoder] at [2007-11-11 11:52:39]
# 1 Re: DB Query in IE vs. Firefox
OK, an update to my problem is I've managed to find a way to get around the caching problem (http://www.howtoadvice.com/StopCaching). My code looks like this:

...
countrySel = createSelect( "countrySel", countries, anchorTop + lineDist*3, anchorTF, 80 );
countrySel.onchange =
new Function( "ajaxProvince.open( 'GET', 'getProvinces.php?country=' + this.value + '&variance=' + new Date().getTime() ); ajaxProvince.send( null );" );
profileForm.appendChild( countrySel );
...

ajaxProvince.onreadystatechange = function()
{
alert('here'); // Debug msg
if(ajaxProvince.readyState == 4)
{
provState = new Array();
var provArr = ajaxProvince.responseText.split( '|' );

for( var i = 1; i < provArr.length; i++ )
{
provState.push( provArr[i] );
}
fs_store.removeChild( provStateSel );
if( browser == 'IE' )
provStateSel = createSelect( "provStateSel", provState, lineDist * 3 + 24, 310, 90 );
else
provStateSel = createSelect( "provStateSel", provState, lineDist * 3 + 10, 310, 90 );

fs_store.appendChild( provStateSel );
}
}

Again, in FF this works but IE still gives me grief.
canadiancoder at 2007-11-11 23:42:03 >
# 2 Re: DB Query in IE vs. Firefox
Hi folks,

To continue my updates I managed to defeat one problem, that is the using one DDM to spawn the contents of another. Essentially I had to re-create my AJAX object each time I made a new selection. I couldn't find a slicker way of doing this but it works.

However, in the spirit of dev work with IE I fixed one problem only to encounter another. I want to a) select a country which then b) spawns the DDM of provinces/states which, when selected will produce c) a DDM of time zones.

My database tables are as follows:

TimeZone: text, code
RegionTimeZone: code, province/state (code is FK of TimeZone)

When I query the database I have to use a nested SELECT statement as follows:

SELECT text FROM TimeZone WHERE code = (SELECT code FROM RegionTimeZone WHERE province_state = xxx);

This can potentially cause problems b/c the second select statement can return multiple rows. To get around this I broke it into two statements so I get the codes first and then in my program I run a loop which then calls the first select statement above on each of those codes to get the text.

Here are the two functions that drive this:

var ajaxTimeZones;
var ajaxTimeZoneText;

function timeZonesTextFunc( timeZone )
{
ajaxTimeZoneText = ajaxInit();

ajaxTimeZoneText.onreadystatechange = function()
{
if( ajaxTimeZoneText.readyState == 4 )
{
var timeZoneText = ajaxTimeZoneText.responseText;

fs_store.removeChild( timeZoneSel );

timeZones.push( timeZoneText );

if( browser == 'IE' )
timeZoneSel = createSelect( "timeZoneSel", timeZones, lineDist * 4 + 24, 310, 90 );
else
timeZoneSel = createSelect( "timeZoneSel", timeZones, lineDist * 4 + 10, 310, 90 );

if( timeZones.length == 1 )
timeZoneSel.disabled = true;

fs_store.appendChild( timeZoneSel );
}
}
ajaxTimeZoneText.open( 'GET', 'getTimeZoneText.php?code=' + timeZone + "&variance=" + new Date().getTime() );
ajaxTimeZoneText.send( null );
}

function timeZoneFunc()
{
ajaxTimeZones = ajaxInit();

ajaxTimeZones.onreadystatechange = function()
{
if( ajaxTimeZones.readyState == 4 )
{
var timeZonesArr = ajaxTimeZones.responseText.split( '|' );
timeZones = new Array();

for( var i = 0; i < timeZonesArr.length - 1; i++ )
{
alert( 'debug' );
timeZonesTextFunc( timeZonesArr[i] );
}
}
}
}

In FF this works just fine but in IE if I remove the "alert( 'debug' );" I get the last time zone text.

I've tried to put a while loop in place of the debug statement just to see if it's the timing but alas it didn't work.

The obvious questions are; why does this work when I put in the alert box and how can I make it work without the box?

Thanks!
canadiancoder at 2007-11-11 23:42:57 >