Solved

not implemented error: javascript/ajax in asp page

Posted on 2007-04-06
4
516 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
Comment Utility
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
Comment Utility
do ya mean
document.getElementById(theList).innerHTML = xmlhttp.responseText;
instead of
document.getElementById(loadList).innerHTML = xmlhttp.responseText;


0
 
LVL 15

Expert Comment

by:stanscott2
Comment Utility
yes
0
 

Author Comment

by:razzzzer
Comment Utility
that seems like it would work just fine...

thanks
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

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 …
This article discusses how to create an extensible mechanism for linked drop downs.
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 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 …

744 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

18 Experts available now in Live!

Get 1:1 Help Now