Solved

not implemented error: javascript/ajax in asp page

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

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

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…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn how to count occurrences of each item in an array.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

770 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