User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 422,602 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,644 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1282 | Replies: 1
Reply
Join Date: Oct 2007
Posts: 8
Reputation: Dennis_Phils is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Dennis_Phils Dennis_Phils is offline Offline
Newbie Poster

Help xmlDoc.onload problem, sequence of execution for Firefox

  #1  
Jan 21st, 2008
Hi everyone, I'm having problem with the sequence of execution for xml.onload. It works fine if your not passing parameters to onload event but my code needs to pass parameter to its function. I'm able to research ablut passing parameters for onload event.

However my problem is it only executes on the last instance of loading the XML.

I'm sure ur all pretty confused. I'll show some of the javascript code:

<script type="text/javascript">
var xmlDoc;

Load_XML("Organizations.xml", "organization_");
Load_XML("Restrictions.xml", "restrictions_");
Load_XML("Country.xml", "country_");

function Load_XML(XMLfilePath, Prop)

{ //IE
if (window.ActiveXObject)
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.onreadystatechange = function ()
{
if (xmlDoc.readyState == 4)
{
displayDecoded_Value(Prop);
}

}
}

else if (document.implementation && document.implementation.createDocument)

{ //Firefox
xmlDoc=document.implementation.createDocument("","",null);
xmlDoc.onload = function (evt) { displayDecoded_Value(Prop); }
}

xmlDoc.load(XMLfilePath)

}

function displayDecoded_Value(prop)
{
//code here to decode the values, includes looping to the child nodes of the XML documents and assigning the matched value to a variable
}


I have here 3 instances to load the XML. Each XML is loaded, the DecodeValues function is used to decode the values based on the parameter passed.

In IE, the sequence of execution is that, First LoadXML is executed and calls on to the function LoadXML, then checks the browser used. If IE is used, the onreadystatechanged is executed and checks if it is equal to 4 and calls the DecodeValues function and loads the XML document. After executing the DecodeValues function, it goes back to execute the Second LoadXML. and so on. There's no problem here.

In Firefox, the sequence of execution is that, First LoadXML is executed and calls on to the function LoadXML, then checks the browser used. If Firefox is used, the onload event is called. In here I passed a parameter to the DecodeValues function. But the problem here is the DecodeValues function is only called at the last instance of LoadXML which is the Third LoadXML. So the only property that is decoded is the Third LoadXML, the country property.

Is my onload event syntax correct for Firefox???

Can anyone help me???
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jan 2007
Posts: 2,556
Reputation: MidiMagic is on a distinguished road 
Rep Power: 7
Solved Threads: 114
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Posting Maven

Re: xmlDoc.onload problem, sequence of execution for Firefox

  #2  
Jan 21st, 2008
This is one thing you really do not have control over.

Why not instead try to make your conde cross-browser compatible.
Daylight-saving time uses more gasoline
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 2:27 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC