var search = document.getElementById("search");
search.onclick = function(){
var request = null;
if(XMLHttpRequest){
request = new XMLHttpRequest();
}else{
request = new ActiveXObject("Microsoft.XMLHTTP");
}
// 发送ajax请求
var request = new XMLHttpRequest();
request.open("GET","dome.php?number="+document.getElementById("keyword").value);
request.send();
request.onreadystatechange = function(){
if(request.readyState === 4){
if(request.status ===200){
document.getElementById("searchResult").innerHTML = request.responseText;
}else{
alert("发生错误:"+request.status);
}
}
}
}
var save = document.getElementById("save");
save.onclick = function(){
// 发送ajax请求
var request = null;
if(XMLHttpRequest){
request = new XMLHttpRequest();
}else{
request = new ActiveXObject("Microsoft.XMLHTTP");
}
request.open("POST","dome.php");
var data = "name="+document.getElementById("staffName").value
+"&number="+document.getElementById("staffNumber").value
+"&sex="+document.getElementById("staffSex").value
+"&job="+document.getElementById("staffJob").value;
request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
request.send(data);
request.onreadystateonchange = function(){
if(request.readyState===4){
if(request.status===200){
document.getElementById("createResult").innerHTML=request.responseText;
}else{
alert("发生错误:"+request.status);
}
}
}
}