Reputation: 11
I am new to jsp. I have the list of names in the database. I need to get the list of names at the time of enter the values in the textbox as like a google search(using Ajax). I need the simple sample for this.Can anyone help me !!!!!
Upvotes: 0
Views: 76
Reputation: 59670
Do as Follows:
In Javascript using Ajax:
xmlhttp=new XMLHttpRequest();
url=url+"?val="+str1;
xmlhttp.open("POST",url,false);
xmlhttp.send(null);
document.getElementById('my2').innerHTML=xmlhttp.responseText;
Where url
will be the URL to which you will post data. Str1
is the typed value in textbox. and my2
is the box which you will show as auto suggest.
At serverside coding in Servlet get the names from db and send it in response to display.
Upvotes: 0