Solved

not implemented error: javascript/ajax in asp page

Posted on 2007-04-06
4
519 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
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.
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
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…

821 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