Solved

not implemented error: javascript/ajax in asp page

Posted on 2007-04-06
4
517 Views
Last Modified: 2008-01-09
hiya experts...

I have a little problem with an asp/ajax/javascript script.....

i know this statement works:
xmlhttp.onreadystatechange=loadList;

the problem is i have about 20 different situations to check for and i can do something like this to call the right "loadlist":
eval("xmlhttp.onreadystatechange=loadList"+theList);
where "theList" is the current list needed. Only problem is that i need to create 20 or so functions called
loadlistSOMETHING() .....

i tried various ways to send an argument to loadlist like:
xmlhttp.onreadystatechange=loadList("something");
or
xmlhttp.onreadystatechange=loadList(varforlist);

but i get a "not implemented" error...

can you not send arguments to this type of function??

function loadList(theList) {
      if (xmlhttp.readyState==4) {
          if (xmlhttp.status==200) {
                   document.getElementById(theList).innerHTML=xmlhttp.responseText;
        }
    }
}


thanks,
rich
0
Comment
Question by:razzzzer
  • 2
  • 2
4 Comments
 
LVL 15

Accepted Solution

by:
stanscott2 earned 125 total points
ID: 18868009
When you set the onreadystatechange event this way, no, you CAN'T send an argument.  However, that doesn't mean you can't do something like this:

var theList;

function doTheXMLHTTP() {
      theList = something;
      xmlhttp.onreadystatechange = loadList;
}

function loadList() {
     document.getElementById(loadList).innerHTML = xmlhttp.responseText;
}

Just set up your list as a global variable, in other words, so you don't need to pass it directly to the other function.
0
 

Author Comment

by:razzzzer
ID: 18868020
do ya mean
document.getElementById(theList).innerHTML = xmlhttp.responseText;
instead of
document.getElementById(loadList).innerHTML = xmlhttp.responseText;


0
 
LVL 15

Expert Comment

by:stanscott2
ID: 18868041
yes
0
 

Author Comment

by:razzzzer
ID: 18868050
that seems like it would work just fine...

thanks
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

911 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

20 Experts available now in Live!

Get 1:1 Help Now