脚本在谷歌浏览器中传递变量,但不传递IE

时间:2016-03-22 10:23:16

标签: javascript ajax google-chrome internet-explorer asp-classic

我有一些ASP代码,可以显示组织中的所有人。我还允许用户选择服务区域(公司),并且使用AJAX,它将带回公司内部的部门列表,用户可以根据部门和服务区域过滤结果。我有以下ASP代码:

<%@ Language="VBScript"%>
<% response.Buffer = TRUE
'Defines the variables and objects
dim ADUser, RecordList, intOne, intTwo, intThree, companies, service_area, department, arrComp
'Assigns the objComp and objDept variables to Scripting Dictionary objects
%>
<!--#include file="includes/functions.asp"-->
<!--#include file="includes/display.asp"-->
<!--#include file="includes/results.asp"-->
<!--#include file="includes/timer.asp"-->
<h1>Organisational Structure</h1>
<div class="commandspace">
<p class="infotext">The org structure can be viewed with or without staff, indented or left justified.</p>
</div>
</div>
<% 
ADUser = "LDAP://EXAMPLE/OU=Staff,OU=Users,DC=domain,DC=internal"
' Make AD connection and run query
Set objCon = Server.CreateObject("ADODB.Connection")
objCon.provider ="ADsDSOObject"
objCon.Properties("User ID") = "EXAMPLE\User"
objCon.Properties("Password") = "Password"
objCon.Properties("Encrypt Password") = TRUE
objCon.open "Active Directory Provider"
Set objCom = CreateObject("ADODB.Command")
Set objCom.ActiveConnection = objCon 
objCom.CommandText ="select company FROM '"& ADUser &"' where company ='*'" 
Set objRS = objCom.Execute 'Creates an object and runs the LDAP query
Set arrComp = Server.CreateObject("Scripting.Dictionary")
companies = objRS.GetRows()
for intOne = 0 to UBound(companies, 2)
    if Not arrComp.exists(companies(0, intOne)) then
        arrComp.add companies(0, intOne), companies(0, intOne)
    End if
next
response.write "<form action='index.asp?View=Structure' method='POST'>"
response.write "<select id='service_area' name='service_area' onChange='showTeams(this.value)'>"
response.write "<option>Please Select</option>"
For Each item in arrComp.Items
    response.write "<option value='"& Server.URLEncode(item) &"'>" & item & "</option>"  & VBCrlF
next
response.write "</select>"   & VBCrlF
response.write "<span class='structure-spacing'></span>"  & VBCrlF
response.write "<select id='department' name='department'>"
response.write "<option value='-1'>Please Select</option>"
response.write "</select>"  & VBCrlF
response.write "<span class='structure-spacing'></span>"  & VBCrlF
response.write "<input type='submit' name='submit' id='submit'>"  & VBCrlF
response.write "</form>"  & VBCrlF
if request.form("submit")="Submit" then
service_area = request.form("service_area")
department = request.form("department")
if service_area = "Please Select" then 

response.write "<p>Service area cannot be left empty</p>"

end if
     objCom.CommandText ="select company, department, title, cn FROM '"& ADUser &"' where department = '" & department & "' ORDER BY department" 
else
    objCom.CommandText ="select company, department, title, cn FROM '"& ADUser &"' where company ='*' ORDER BY department" 
end if
Set objRS = objCom.Execute 'Creates an object and runs the LDAP query
RecordList = objRS.GetRows()
response.write "<table>"  & VBCrlF
response.write "<thead>"  & VBCrlF
response.write "<tr>"  & VBCrlF
response.write "<th>Service Area</th>"  & VBCrlF
response.write "<th>Department</th>"  & VBCrlF
response.write "<th>Job Title</th>"  & VBCrlF
response.write "<th>Name</th>"  & VBCrlF
response.write "</tr>"  & VBCrlF
response.write "</thead>"  & VBCrlF
response.write "<tbody>"  & VBCrlF
for intThree = 0 to UBound(RecordList,2)
    response.write "<tr class='command'>"  & VBCrlF
    response.write "<td>" & RecordList(3, intThree) & "</td>"  & VBCrlF
    response.write "<td>" & RecordList(2, intThree) & "</td>"  & VBCrlF
    response.write "<td>" & RecordList(1, intThree) & "</td>"  & VBCrlF
    response.write "<td>" & RecordList(0, intThree) & "</td>"  & VBCrlF
response.write "</tr>"  & VBCrlF
next
response.write "</tbody>"  & VBCrlF
response.write "</table>"  & VBCrlF
objRS.Close
objCon.Close
Set objCon = Nothing
Set objCom = Nothing
%>

我有以下AJAX代码

    function showTeams(str) {

        if (str=="") {
            document.getElementById("department").innerHTML="";
            return;
        } 

        if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp=new XMLHttpRequest();
        }
        else {// code for IE6, IE5
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange=function() {
            if (xmlhttp.readyState==4 && xmlhttp.status==200) {
                document.getElementById("department").innerHTML=xmlhttp.responseText;
            }
        }
        xmlhttp.open("GET","get_teams.asp?q="+str,true);
        xmlhttp.send();
    }    

我的问题是,当用户点击结构页面中的提交按钮时;谷歌Chrome将通过变量,但IE不会,我不知道为什么

0 个答案:

没有答案