|
AJAX - Error: Not Implemented
Hi All,
I am having problems with AJAX. Hopefully someone out there has a solution. I have a classic asp program where I am trying to populate a 2nd drop down list based on the first one. However, when I try this i get an error that merely say "not implemented". Below I've trimmed down the code.
Here is the code in the asp program:
<tr>
<td>Agent:</td>
<td>
<Select name="selAgent" onChange='JavaScript:GetAName (this.value,"selectAgentName");'>
<%for x = 0 to nbrAgent%>
<option value="<%=arrAgent(0,x)%>"><%=arrAgent(1,x)%></option>
<%next%>
</select>
</td>
<td>Name</td>
<td id="selectAgentName"></td>
</tr>
Following is the GetAName javascript:
var xmlHttp
var DropDownContainer
function GetAName(str,containerid){
DropDownContainer=containerid;
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null){
alert ("Your browser does not support AJAX!");
return;
}
var url="GetAgentName.asp";
url=url+"?AN="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged();
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
} // end function DupSSN
function stateChanged(containerid){
alert(DropDownContainer + " - " + xmlHttp.readyState);
if (xmlHttp.readyState==4){
//alert(xmlHttp.responseText);
document.getElementById(DropDownContainer).innerHTML=xmlHttp.responseText;
}
} // end functon stateChanged
function GetXmlHttpObject(){
var xmlHttp=null;
try{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e){
// Internet Explorer
try{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e){
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
} // end function GetXmlHttpObject
Following is the GetAgentName.asp
<%
Dim AgentNumber
Dim sqlAN, rsAN, arrAN, x, nbrAN
AgentNumber = trim(request("AN")
sqlAN = "Select AgentNameNbr, AgentName " & _
"From AgentName " & _
"Where AgentNbr = '" & AgentNumber & "' " & _
"Order by AgentName"
Set rsAN = Conn.execute(sqlAN)
arrAN = rsAN.getrows
nbrAN = UBOUND(arrAN,2)
rsAN.close
Set rsAN = Nothing
response.write "<Select name=selAgentName>"
response.write "<option value=-1></option>"
for x = 0 to nbrAN
response.write "<option value=" & arrAN(0,x) & ">" & arrAN(1,x) & "</option>"
next
response.write "</select>"
%>
The alert in the function statechanged will give me the ID of the field and 0 as the value of the readyState. I have verifed that the GetNameAgent.asp does work by running the program in I.E. (ver 7). I know it must be something that I am doing. Any Help would be appreciative.
TIA,
Frates
|