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???

This is one thing you really do not have control over.

Why not instead try to make your conde cross-browser compatible.

This article has been dead for over six months. Start a new discussion instead.