1: jquery-1.3.2.js , , jsp
2: jsp js
$.ajax({
type: "POST",
url: "login.do", ---------
data:"a="+id+“&b=”+name, -----------
success: function(msg){------------ ,
method(msg); method , , alert(msg)
}
});
3: , :jsp
:<input type="text" id="name" name="name"><span id="name2"></span>
js id name , / onfocus,onblur ,
window.onload=onReady;
function onReady(){
var nameObj=document.getElementById("name");
sql :select * from Users where userName=name,
0, 1, meg 0 1,
nameObj.onblur=function checkName(){
var name= nameObj.value;
$.ajax({
type: "POST",
url: "login.do",
data:"a="+name,
success: function(msg){
result(msg);
}
});
}
}
function result(msg){
var resuObj= document.getElementById("name2");
if(msg==0){
resuObj.innerHTML=" ";
}else{
resuObj.innerHTML=" ";
}
}
3: login.do name, , servlet String name=request.getParameter("name")