[Javascript] Multiple ajax calls onload

Murphy, Matt Matt.Murphy at thermofisher.com
Wed Jul 25 12:22:56 CDT 2007


 
My apologies on the reply...

Well, this seems to work if I use two different ajaxme scripts with two
different names of the httprequest object. 

So the question is, is there a way to use variable variables like in PHP
to do this? 

So I could name each instance of my httprequest object something
different? 

Matt

-----Original Message-----
From: javascript-bounces at LaTech.edu
[mailto:javascript-bounces at LaTech.edu] On Behalf Of Scott Reynen
Sent: Wednesday, July 25, 2007 12:01 PM
To: [JavaScript List]
Subject: Re: [Javascript] Multiple ajax calls onload


On Jul 25, 2007, at 10:42 AM, Murphy, Matt wrote:

> All,
>
> I thought I had this ingenious idea, to make a slow-loading page load 
> faster, I'd break up the sections into divs, and then call a series of

> ajax functions to populate those divs asynchronously.
>
> Problem is, only the last one called shows up. I can see in the 
> firefox error log that both document.getElementById 
> ('mydiv').innerHTML="myhtml"
> calls ran, (the output of the php scripts called) but only one showed 
> up.

It's hard to know without looking at your ajaxme() function, but if both
calls are setting innerHTML on the same div, the last one to run is
overwriting all the others.  It would be better to change that to
something like this (untested):

var newDiv = document.createElement( 'div' ); newDiv.innerHTML =
"myhtml"; document.getElementById('mydiv').appendChild( newDiv );

Also, please don't use "Reply" to start a new thread.  Some of us are
using threaded email clients that get confused by that.

Peace,
Scott
_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript



More information about the Javascript mailing list