Javascript - array of XmlHttpRequest objects

Posted on 2009-02-12
Last Modified: 2012-05-06
I've got an application that builds block of javascript code dynamically and then adds it to the page.  The code that is built dynamically is...

<script>var XHRList = new Array();XHRList[0] = CreateXmlHttpRequestObject();XHRList[1] = CreateXmlHttpRequestObject();XHRList[2] = CreateXmlHttpRequestObject();XHRList[3] = CreateXmlHttpRequestObject();XHRList[4] = CreateXmlHttpRequestObject();XHRList[5] = CreateXmlHttpRequestObject();XHRList[6] = CreateXmlHttpRequestObject();</script>

The javascript function CreateXmlHttpRequestObject() is already part of the page that the above code is being added to and I have verified that it does return an XmlHttpRequest object.  Yet, when the page starts to run the above block of code that is trying to create an array of XmlHttpRequest objects, I'm getting an error on the first saying "Object Expected".

Do I have to do something special to stick these objects inside of an array?
Question by:josephdaviskcrm
    LVL 15

    Accepted Solution

    can u show us your CreateXmlHttpRequestObject() ?
    LVL 29

    Expert Comment

    <$.02>And for heaven's sake, use a little whitespace.</$.02>

    Author Comment

    nevermind... I figured it out on my own.
    LVL 29

    Expert Comment

    Show us what you did, please.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Javascript: Crash Course

    Javascript is not only emerging as the most important language to know, it's flexibility is unique. With Javascript being deployed on the web, mobile and even the desktop this is the one language that all technologists need to know.

    Article by: DanRollins
    This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (, we'll extend the program by adding a depth-…
    Introduction HyperText Transfer Protocol ( or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    760 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

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now