Function implementation:
Fill in the text box content in the JSP page, the cursor leaves the text box, in the corresponding place of this page obtains the other data which the database changes the value corresponding.
Servlet:
Request.setcharacterencoding ("Utf-8");
PrintWriter out = Response.getwriter ();
Call the servlet layer to go to the database to find out if there are identical user names and return to other records on the page
String client_id = Request.getparameter ("client_id");
Clientservices clientservices = new Clientservices ();
try {
thread.sleep;
} catch (Interruptedexception e) {
e.printstacktrace ();
}
Client client = Clientservices.findclientbyid (client_id);
if (client!= null) {
out.print (Urlencoder.encode (Client.getclient_name (), "Utf-8"));
} else {
Out.print ("false");
}
Out.flush ();
Out.close ();
Jquery:
$ (document). Ready (function () {$ ("#client_id"). blur (function () {$.ajax ({type: ' POST '), u RL: ' servlet/validservlet?client_id= ' + $ (this). Val (), Data: ' client_id= ' + $ ("#client_id"). Val (), Success:function (ms g) {if (msg = = ' false ') {alert ("No this Person");} else {//utf-8 decoding resolves Chinese garbled $ ("#clientInfo"). HTML (decodeURI (msg)); $ ("#clientInfo")
. attr ("Value", decodeURI (msg));
}
}
});
});
});