日期:2014-05-16 浏览次数:20713 次
function sendData() { var xmlHttp; if (window.ActiveXObject) //是否支持ActiveX控件 { //支持ie为构造函数输入参数Microsoft.XMLHTTP,创建一个XMLHttpRequest xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } //ActiveXObject创建失败,非ie else if (window.XMLHttpRequest) { xmlHttp = new XMLHttpRequest(); } else { window.alert("该浏览器不支持AJAX,请更换浏览器"); } if (xmlHttp != null) {//对象实例化成功 开始干活0.0 var CurrPage = document.getElementById("lblCurrPage").innerHTML; xmlHttp.open("get", "AjaxLoginEmps.aspx?CurrPage=" + CurrPage + "&p=" + Math.random(), true); //调用open()方法并采用异步方式 xmlHttp.onreadystatechange = function() { alert(xmlHttp.readyState); if (xmlHttp.readyState == 4 && xmlHttp.status == 200) { var objs = xmlHttp.responseText; objs = eval("(" + objs + ")"); objs = objs.Province; var drp = document.getElementById("drpPro"); for (var i = 0; i < objs.length; i++) { var opt = document.createElement("option"); opt.text = objs[i].name; opt.value = objs[i].id; drp.options.add(opt); } } else { } } xmlHttp.send(null); } }