heyy can ny 1 help me.....m wrking on jsp using ajax......i built a small application...as m new to ajax.....i built 2 field....FNAME & Lname and when my application used to do is..when you enter ur first name.....n press the tab button...the last name shld come from data base......but its nt wrking.....can ny 1 help me !!
file name-"Myform.html" -
<html>
<head>
<title></title>
</head>
<body bgcolor="#008000">
<centre>
ENTER THE WORLD
</centre>
<script type="text/javascript">
function ajaxFunction1()
{
alert("sss");
var xmlhttp;
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
alert("Your browser does not support XMLHTTP!");
}
var url="Lname.jsp?fname=shankey";
alert(url);
xmlhttp.onreadystatechange=XLNAME()"{
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function XLNAME(){
alert("hello");
if(xmlhttp.readyState==4)
{
document.myform.lname.value=xmlhttp.responseText;
}
}
}
</script>
<form name="myform">
F.Name:<input type="text" name="fname" onBlur="ajaxFunction1();" >
L.Name:<input type="text" name="lname" >
</form>
</body>
</html>
and
file name-"Lname.jsp"
<%@ page language="java" import="java.sql., java.io." %>
<%@ page import="java.util.*" %>
<%
String sn="";
String str1=request.getParameter("fname");
//String str2=request.getParameter("lname");
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.101:1521:ORCL","SHANKEY","SHANKEY");
Statement pst=con.createStatement();
String query="select Surname from DATA1 where Name='"str1"'" ;
//out.print(query);
ResultSet rst=pst.executeQuery(query);
while(rst.next()){
sn=rst.getString("Surname");
}
//else{
//response.sendRedirect("Myform.html");
out.println(sn);
//}
}catch(Exception e)
{
out.println("Exception:"+e);
}
%>
....................................can ny 1 help me out