Solved

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

Posted on 2007-11-26
2
204 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 500 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

726 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