AJAX page chugs in Firefox; Konqueror is fine
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Ben_Forbes
Posted On:   Wednesday, December 20, 2006 08:26 AM

I made my first AJAX application today. It's simple; there's a text box and button. When the button is pressed, the contents of the text box are passed to a PHP script and a list of words that match is returned. I then populate a table with those results. There's about 100 words total. It works okay, but Firefox starts chugging after a dozen or so queries. Actually, just the tab with the AJAX in it chugs. Other tabs and windows are fine. I thought I could fix it by reusing TRs and TDs in the table, but the problem is still there. In Konqueror there is absolutely no problem, it runs fine. Could this be    More>>

I made my first AJAX application today. It's simple;
there's a text box and button. When the button is
pressed, the contents of the text box are passed to a PHP
script and a list of words that match is returned.
I then populate a table with those results.


There's about 100 words total.




It works okay, but Firefox starts chugging after a dozen
or so queries. Actually, just the tab with the AJAX in
it chugs. Other tabs and windows are fine. I thought I
could fix it by reusing TRs and TDs in the table, but
the problem is still there.




In Konqueror there is absolutely no problem, it runs fine.




Could this be some kind of memory drain issue?
I've heard Firefox is pretty bad with memory,
although honestly I've never noticed in the few years
I've been using it.




Or could it be the fact that I'm
dynamically manipulating the DOM tree? Konqueror may
be more efficient in doing this.




Here's a bit of code:

			
function alertContents(http_request) {

if (http_request.readyState == 4) {
if (http_request.status == 200) {
var txt=http_request.responseText;
var arr=txt.split(",");
clearResults();
for (var i=0;i
addResult(arr[i]);
}
} else {
alert('There was a problem with the request.');
}
}

}
function clearResults() {
var theTable=document.getElementById('theTable');
var rows=theTable.getElementsByTagName('tr');
while (rows.length>1) {
rowStore.push(rows[1]);
rows[1].parentNode.removeChild(rows[1]);
}
}
function addResult(s) {
var theTable=document.getElementById('theTable');

//var newTr=document.createElement('tr');
//var newTd=document.createElement('td');
//Be nice
var newTr;
var newTd;
if (rowStore.length>0) {
newTr=rowStore.pop();
var tds=newTr.getElementsByTagName('td');
newTd=tds[0];
}
else {
newTr=document.createElement('tr');
rowsCreated++;
var theSpan2=document.getElementById('theSpan2');
theSpan2.innerHTML=rowsCreated;
newTd=document.createElement('td');
newTr.appendChild(newTd);
}
newTd.innerHTML=s;
newTr.style.borderBottom='1px solid grey';
theTable.appendChild(newTr);
}


   <<Less
About | Sitemap | Contact