Posted By:
jennifer_yan
Posted On:
Wednesday, July 18, 2007 03:49 AM
I'm on the progress on getting data from MS Access database to be post it to textarea, but a type mismatch error was prompt. Enclosed on the source code, appreciate that you can help me to debug the above problem. testajax.asp function.js var xmlHttp function showCustomer(frm,str) { xmlHttp=GetXmlHttpObject(); if (xmlHttp==null) { alert ("Your browser does not support AJAX!"); return; } var url="getcustomer.asp"; url=url+"?q="+str; alert (url) url=url+"&sid="+Math.random();
More>>
I'm on the progress on getting data from MS Access database to be post it to textarea, but a type mismatch error was prompt.
Enclosed on the source code, appreciate that you can help me to debug the above problem.
testajax.asp
function.js
var xmlHttp
function showCustomer(frm,str)
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url="getcustomer.asp";
url=url+"?q="+str;
alert (url)
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged(frm);
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function stateChanged(frm)
{
if (xmlHttp.readyState==4)
{
var xmlDoc=xmlHttp.responseXML.documentElement;
frm.pro_company.value = xmlDoc.getElementsByTagName("pro_buyer")[0].childNodes[0].nodeValue;
}
}
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;
}
getcustomer.asp
<%
response.expires=-1
response.contenttype="text/xml"
sql="SELECT * FROM prospect WHERE pro_icno="
sql=sql & "'" & request.querystring("q") & "'"
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("../db/prospectivebuyer.mdb"))
set rs = Server.CreateObject("ADODB.recordset")
rs.Open sql, conn
response.write("
<?xml version='1.0' encoding='ISO-8859-1'?>")
response.write("
")
response.write("
" &rs.fields("pro_buyer")& "
")
response.write("
")
set rs=nothing
set conn=Nothing
%>
<<Less