Checking when Microsoft.XMLDOM is done with XML import?

J

jfizer

I have a web app that uses a form with its fields populated from XML
using Microsoft.XMLDOM. The problem is that Microsoft.XMLDOM functions
seem to run on their own thread, so I dont know when the fields are
done populating.

Can anyone think of a way for me to check when the following function
finishes?

function importXML(xmlQuery,xmlSrc,xmlTarget)
{
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.onreadystatechange = function () {
if (xmlDoc.readyState == 4)
parseXML(xmlQuery,xmlSrc,xmlTarget,xmlDoc)
};


xmlDoc.load("http://home1/sandbox/XMLResponder.nsf/XMLResponder?openagent&frm="+
xmlSrc +"&z=.xml");
return true;
}

function parseXML(xmlQuery,xmlSrc,xmlTarget,xmlDoc)
{
var x = xmlDoc.getElementsByTagName('field');
var sValue;
var sText;
for (i=0;i<x.length;i++)
{
var row = document.createElement('TR');
for (j=0;j<x.childNodes.length;j++)
{
if (x.childNodes[j].nodeType != 1)
continue;
sValue =
x.childNodes[j].firstChild.nodeValue;
j++;
sText =
x.childNodes[j].firstChild.nodeValue
addOption(xmlTarget,sText,sValue);
}
}
}
 
S

Steve van Dongen

jfizer said:
I have a web app that uses a form with its fields populated from XML
using Microsoft.XMLDOM. The problem is that Microsoft.XMLDOM functions
seem to run on their own thread, so I dont know when the fields are
done populating.

Can anyone think of a way for me to check when the following function
finishes?

function importXML(xmlQuery,xmlSrc,xmlTarget)
{
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.onreadystatechange = function () {
if (xmlDoc.readyState == 4)
parseXML(xmlQuery,xmlSrc,xmlTarget,xmlDoc)
};


xmlDoc.load("http://home1/sandbox/XMLResponder.nsf/XMLResponder?openagent&frm="+
xmlSrc +"&z=.xml");
return true;
}

function parseXML(xmlQuery,xmlSrc,xmlTarget,xmlDoc)
{
var x = xmlDoc.getElementsByTagName('field');
var sValue;
var sText;
for (i=0;i<x.length;i++)
{
var row = document.createElement('TR');
for (j=0;j<x.childNodes.length;j++)
{
if (x.childNodes[j].nodeType != 1)
continue;
sValue =
x.childNodes[j].firstChild.nodeValue;
j++;
sText =
x.childNodes[j].firstChild.nodeValue
addOption(xmlTarget,sText,sValue);
}
}
}


The XML document is loaded when xmlDoc.readyState == 4 and the fields
are populated when the parseXML function finishes.

Regards,
Steve
 
J

jfizer

jfizer said:
I have a web app that uses a form with its fields populated from XML
using Microsoft.XMLDOM. The problem is that Microsoft.XMLDOM functions
seem to run on their own thread, so I dont know when the fields are
done populating.

Can anyone think of a way for me to check when the following function
finishes?

function importXML(xmlQuery,xmlSrc,xmlTarget)
{
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.onreadystatechange = function () {
if (xmlDoc.readyState == 4)
parseXML(xmlQuery,xmlSrc,xmlTarget,xmlDoc)
};


xmlDoc.load("http://home1/sandbox/XMLResponder.nsf/XMLResponder?openagent&frm="+
xmlSrc +"&z=.xml");
return true;
}

function parseXML(xmlQuery,xmlSrc,xmlTarget,xmlDoc)
{
var x = xmlDoc.getElementsByTagName('field');
var sValue;
var sText;
for (i=0;i<x.length;i++)
{
var row = document.createElement('TR');
for (j=0;j<x.childNodes.length;j++)
{
if (x.childNodes[j].nodeType != 1)
continue;
sValue =
x.childNodes[j].firstChild.nodeValue;
j++;
sText =
x.childNodes[j].firstChild.nodeValue
addOption(xmlTarget,sText,sValue);
}
}
}


The XML document is loaded when xmlDoc.readyState == 4 and the fields
are populated when the parseXML function finishes.

Regards,
Steve


I am aware of this, however my problem is as follows.

I have four select lists. The user can select items from list A and
add or delete them from list B. Depending on whats in list B, list C
gets populated via XML. The user can then select items from list C and
add or remove them from list D. The problem is when there are items in
list D and the user then removes an item from list B. This means that
list C changes and I need to make sure that the selected items that
got inserted into list D are still in list C. I've not been able to
find a way to do this because I dont know when list C is done being
populated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top