Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Multiple AJAX scripts/functions in one page only runs last function

Posted on 2007-11-26
2
Medium Priority
?
208 Views
Last Modified: 2012-08-14
I've got a page with 3 divs that I need filled using AJAX.  So I've got 3 js functions to accomodate that.  This is how I've got the section of the page:

<div id="Sect1"></div>
<script type="text/javascript">loadSect1();</script>

<div id="Sect2"></div>
<script type="text/javascript">loadSect2();</script>

div id="Sect3"></div>
<script type="text/javascript">loadSect3();</script>

------------
The problem I'm having is that only the last javascript function seems to be executing.  If I re-order the divs with say, Sect1 being last, then that function runs fine, but none of the other 2.  I've included an onclick event on each of the divs and that works but I don't want users to have to click each section to load the data.

What am I missing here?

I thank you in advance.
0
Comment
Question by:leadwave
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 51

Accepted Solution

by:
ahoffmann earned 1500 total points
ID: 20352343
do you functions (loadSect1-3) all use the same function to to make the XmlHttpRequest? Then you most likely have one object which gets overwritten with each call.
You either need to make instanzes of each (xmlhttprequest-)object, or wait 'til the request finished ith a response.
0
 

Author Closing Comment

by:leadwave
ID: 31411026
Thank you.  I knew I was missing something.  I simply created a new instance of the object and everything works great.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question