ajax技术示例
var xmlHttpReq = null;
function getMaxEndCode() {
var DPid = document.getElementById("txtDTId").value;
//除IE5、IE6以外,XMLHttpRequest是其它浏览器的子对象
if (window.XMLHttpRequest) {
xmlHttpReq = new XMLHttpRequest();
}
//IE5.IE6是以ActiveXObj的形式引入XMLHttpRequest的
else if (window.ActiveXObject) {
xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
//判断xmlHttpReq是否申明成功,若成功则发出请求
if (xmlHttpReq != null) {
xmlHttpReq.open("post", "Ajax/GetMaxEndCode.aspx", true);
//url传值
// xmlHttpReq.open("post", "/Ajax/getMaxEndCode.aspx?positionx="+x+"&positiony="+y, false);
var postval = "DTId=" + DPid;
//设置回调函数
xmlHttpReq.onreadystatechange = requestPostback;
xmlHttpReq.setRequestHeader(" Content-Type ", " application/x-www-form-urlencoded "); //用post方法的话,一定要加这句。
xmlHttpReq.send(postval);
}
}
function requestPostback() {
if (xmlHttpReq.readyState == 4) {
var requestback = xmlHttpReq.responseText;
document.getElementById("StartCode").value =requestback;
}
var xmlHttpReq = null;
function getMaxEndCode() {
var DPid = document.getElementById("txtDTId").value;
//除IE5、IE6以外,XMLHttpRequest是其它浏览器的子对象
if (window.XMLHttpRequest) {
xmlHttpReq = new XMLHttpRequest();
}
//IE5.IE6是以ActiveXObj的形式引入XMLHttpRequest的
else if (window.ActiveXObject) {
xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
//判断xmlHttpReq是否申明成功,若成功则发出请求
if (xmlHttpReq != null) {
xmlHttpReq.open("post", "Ajax/GetMaxEndCode.aspx", true);
//url传值
// xmlHttpReq.open("post", "/Ajax/getMaxEndCode.aspx?positionx="+x+"&positiony="+y, false);
var postval = "DTId=" + DPid;
//设置回调函数
xmlHttpReq.onreadystatechange = requestPostback;
xmlHttpReq.setRequestHeader(" Content-Type ", " application/x-www-form-urlencoded "); //用post方法的话,一定要加这句。
xmlHttpReq.send(postval);
}
}
function requestPostback() {
if (xmlHttpReq.readyState == 4) {
var requestback = xmlHttpReq.responseText;
document.getElementById("StartCode").value =requestback;
}