O
Olorin
Hello everyone. I'm playing around with some AJAX-ish stuff and
encountered some problem in the JS side of the universe. Maybe someone
here can suggest an alternative that works.
I have developed a simple ASP.NET application with a web page that
should display a list of users. This list page is designed to start
with an empty table (with columns defined), and, onload, send an
XmlHttp request to a server component (a.k.a. ListServer). This
ListServer is currently simulating a long-running operation. So, it
sleeps for 3 seconds, and then grabs a list of 4 users from an xml
file. It applies an xsl transformation and returns the result.
The xslt is designed to take the xml data and convert it to a
<ListChunk> root element containing a <tr> for each user in the XML
data. Each row contains 4 columns (Id, Login, Password, Name). The
javascript in the list page grabs the responseXML from the XmlHttp
object and should, for each <tr> in it, create a copy of the row
coming from the server and adding it to the list on the client.
I actually got all that to work quite fine. The js snipplet dealing
with copying the row coming from the server and adding it to the table
on the client is:
(listChunk is the responsseXML fromt he XmlHttp object, and tableBody
is the body of the table in the page)
var userRows = listChunk.getElementsByTagName("tr");
if(userRows==null || userRows.length==0)
{
EndAsyncLoading();
return;
}
for(var rowIndex=0; rowIndex<userRows.length; rowIndex++)
{
var serverRow = userRows[rowIndex];
var clientRow = tableBody.insertRow(-1);
var serverCells = serverRow.getElementsByTagName("td");
for(var cellIndex=0; cellIndex<serverCells.length; cellIndex+
+)
{
var serverCell = serverCells[cellIndex];
var clientCell = serverCell.cloneNode(true);
clientRow.appendChild(clientCell);
}
}
As you can see, it's a call to insertRow followed by a call to
cloneNode and appendChild for each cell int he row.
Today I modified the xsl on the server to make the Id and Login
columns links. The odd thing is that the table rows added to the table
on the page include the links in the first two cells, but the browser
does not let me click on them.
Even better.. if I save the resulting page locally, and then re-open
it in the same browser, the links are recognized as such and
clickable.
I'm working in Firefox 2 for now, but would certainly like to find a
solution that works at least in FF2 and IE7 (although IE7 is still
yelling at me for using appendChild /sigh)
Thanks in advance,
F.O.R.
encountered some problem in the JS side of the universe. Maybe someone
here can suggest an alternative that works.
I have developed a simple ASP.NET application with a web page that
should display a list of users. This list page is designed to start
with an empty table (with columns defined), and, onload, send an
XmlHttp request to a server component (a.k.a. ListServer). This
ListServer is currently simulating a long-running operation. So, it
sleeps for 3 seconds, and then grabs a list of 4 users from an xml
file. It applies an xsl transformation and returns the result.
The xslt is designed to take the xml data and convert it to a
<ListChunk> root element containing a <tr> for each user in the XML
data. Each row contains 4 columns (Id, Login, Password, Name). The
javascript in the list page grabs the responseXML from the XmlHttp
object and should, for each <tr> in it, create a copy of the row
coming from the server and adding it to the list on the client.
I actually got all that to work quite fine. The js snipplet dealing
with copying the row coming from the server and adding it to the table
on the client is:
(listChunk is the responsseXML fromt he XmlHttp object, and tableBody
is the body of the table in the page)
var userRows = listChunk.getElementsByTagName("tr");
if(userRows==null || userRows.length==0)
{
EndAsyncLoading();
return;
}
for(var rowIndex=0; rowIndex<userRows.length; rowIndex++)
{
var serverRow = userRows[rowIndex];
var clientRow = tableBody.insertRow(-1);
var serverCells = serverRow.getElementsByTagName("td");
for(var cellIndex=0; cellIndex<serverCells.length; cellIndex+
+)
{
var serverCell = serverCells[cellIndex];
var clientCell = serverCell.cloneNode(true);
clientRow.appendChild(clientCell);
}
}
As you can see, it's a call to insertRow followed by a call to
cloneNode and appendChild for each cell int he row.
Today I modified the xsl on the server to make the Id and Login
columns links. The odd thing is that the table rows added to the table
on the page include the links in the first two cells, but the browser
does not let me click on them.
Even better.. if I save the resulting page locally, and then re-open
it in the same browser, the links are recognized as such and
clickable.
I'm working in Firefox 2 for now, but would certainly like to find a
solution that works at least in FF2 and IE7 (although IE7 is still
yelling at me for using appendChild /sigh)
Thanks in advance,
F.O.R.