高分求助~帮忙看下这个ajax怎么复制一份
时间:2011-11-01
来源:互联网
<body onLoad="callServer();callServer1()">
<!--略 -->
<select name="plantname" id="plantname" onchange="callServer()">
<!--略 -->
<select name="employeename" id="employeename" onchange="callServer1()" >
</body>
我这样写为什么不对?
<script>
/* 第一份 */
var xmlHttp = false;
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
xmlHttp = false;
}
}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
xmlHttp = new XMLHttpRequest();
}
function callServer() {
var name = document.getElementById("plantname").value;
if ((name == null) || (name == "")) return;
var url = "loadingdeptname.asp?pl_id=" + escape(name);
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = updatePage;
xmlHttp.send(null);
}
function updatePage() {
if (xmlHttp.readyState < 4) {
depta.innerHTML="正加載部門數據......";
}
if (xmlHttp.readyState == 4) {
var response = xmlHttp.responseText;
depta.innerHTML=response;
}
}
/* 第二份 */
var xmlHttp1 = false;
try {
xmlHttp1 = new ActiveXObject1("Msxml2.xmlHttp1");
} catch (e) {
try {
xmlHttp1 = new ActiveXObject1("Microsoft.xmlHttp1");
} catch (e2) {
xmlHttp1 = false;
}
}
if (!xmlHttp1 && typeof xmlHttp1Request1 != 'undefined') {
xmlHttp1 = new xmlHttp1Request1();
}
function callServer1() {
var name1 = document.getElementById("employeename").value;
if ((name1 == null) || (name1 == "")) return;
var url1 = "loadingemployeename.asp?d_id=" + escape(name);
xmlHttp1.open("GET", url1, true);
xmlHttp1.onreadystatechange1 = updatePage1;
xmlHttp1.send(null);
}
function updatePage1() {
if (xmlHttp1.readyState1 < 4) {
employeen.innerHTML="正加載部門數據......";
}
if (xmlHttp1.readyState1 == 4) {
var response1 = xmlHttp1.responseText;
employeen.innerHTML=response;
}
}
</script>
<!--略 -->
<select name="plantname" id="plantname" onchange="callServer()">
<!--略 -->
<select name="employeename" id="employeename" onchange="callServer1()" >
</body>
我这样写为什么不对?
<script>
/* 第一份 */
var xmlHttp = false;
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
xmlHttp = false;
}
}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
xmlHttp = new XMLHttpRequest();
}
function callServer() {
var name = document.getElementById("plantname").value;
if ((name == null) || (name == "")) return;
var url = "loadingdeptname.asp?pl_id=" + escape(name);
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = updatePage;
xmlHttp.send(null);
}
function updatePage() {
if (xmlHttp.readyState < 4) {
depta.innerHTML="正加載部門數據......";
}
if (xmlHttp.readyState == 4) {
var response = xmlHttp.responseText;
depta.innerHTML=response;
}
}
/* 第二份 */
var xmlHttp1 = false;
try {
xmlHttp1 = new ActiveXObject1("Msxml2.xmlHttp1");
} catch (e) {
try {
xmlHttp1 = new ActiveXObject1("Microsoft.xmlHttp1");
} catch (e2) {
xmlHttp1 = false;
}
}
if (!xmlHttp1 && typeof xmlHttp1Request1 != 'undefined') {
xmlHttp1 = new xmlHttp1Request1();
}
function callServer1() {
var name1 = document.getElementById("employeename").value;
if ((name1 == null) || (name1 == "")) return;
var url1 = "loadingemployeename.asp?d_id=" + escape(name);
xmlHttp1.open("GET", url1, true);
xmlHttp1.onreadystatechange1 = updatePage1;
xmlHttp1.send(null);
}
function updatePage1() {
if (xmlHttp1.readyState1 < 4) {
employeen.innerHTML="正加載部門數據......";
}
if (xmlHttp1.readyState1 == 4) {
var response1 = xmlHttp1.responseText;
employeen.innerHTML=response;
}
}
</script>
作者: shugeer 发布时间: 2011-11-01
你可以
if (xmlHttp.readyState == 4) {
if(xmlHttp.status==200)
{
var response = xmlHttp.responseText;
document.getElementById("depta").innerHTML=response;
}
}
else
{
document.getElementById("depta").innerHTML="正加載部門數據......";
}
if (xmlHttp.readyState == 4) {
if(xmlHttp.status==200)
{
var response = xmlHttp.responseText;
document.getElementById("depta").innerHTML=response;
}
}
else
{
document.getElementById("depta").innerHTML="正加載部門數據......";
}
作者: net_lover 发布时间: 2011-11-01
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28