weixin_33709590 2017-03-20 20:29 采纳率: 0%
浏览 19

在AJAX上丢失到.ASP文件

I have a need to automate data collection for users who visit specific pages of my site. To do this, I'm querying the LDAP. The LDAP query works just fine when I double click on the file locally (.vbs). However, when I double click on it while it's on the server, it doesn't work (as would be expected). However, I'm as new as new can get to writing VBScript.

After reading a few articles I modified the code and changed the extension to .asp. I ended up with this:

<%
    On Error Resume Next

    'Create the Array that will be passed
    Dim employee(7)

    'Employee System Related Info
    Set objSysInfo = CreateObject("ADSystemInfo")

    employee(0) = objSysInfo.SiteName

    'Employee specific information
    strUser = objSysInfo.UserName
    Set objUser = GetObject("LDAP://" & strUser)

    employee(1) = objUser.sAMAccountName
    employee(2) = objUser.givenName
    employee(3) = objUser.sn
    employee(4) = objUser.displayName
    employee(5) = objUser.telephoneNumber
    employee(6) = objUser.title

    Return employee
%>

In the JavaScript function which would call this .asp file via ajax, I am able to get the employee number which I think could be received by the .asp file and do the rest of the query.... However, I'm not even sure if I'm returning everything correctly in the VBScript. Furthermore, I'm not even sure if I should be using a GET or POST AJAX call. Can someone point me in the right direction?

Updated 03/22/2017 at 10AM CDT

I've finally gotten back to the office and tried to play around. I'm still a little lost. I've made some updates to the code below you'll see the javascript and the VBScript

FIRST the JavaScript:

var employee = {};
function getEmp() {
var ldapUserName = ADSystem.UserName;

$.ajax({
    type: "POST",
    data: ldapUserName,
    url: "https://here.is.my/url.asp", 
    success: $.ajax({
             type: "GET",
             dataType: "json",
             success: function(responseText) {
                employee = responseText;
             },
             error: function() {
                    alert("No Data Received");
             }
        }),
    error: function() {
            alert("Connection Failed");
        }
    });
}

Now here is the updated VBScript based on a few things I read and the suggestions from here:

<%
Public Function empDemo(username)

On Error Resume Next
'Create the Array that will be passed
Dim employee(7)

'Employee System Related Info
Set objSysInfo = CreateObject("ADSystemInfo")
employee(0) = objSysInfo.SiteName

'Employee specific information
strUser = objSysInfo.username
Set objUser = GetObject("LDAP://" & strUser)

employee(1) = objUser.sAMAccountName
employee(2) = objUser.givenName
employee(3) = objUser.sn
employee(4) = objUser.displayName
employee(5) = objUser.telephoneNumber
employee(6) = objUser.title

response.write "{ site: " & employee(0) & "," 
        & "empNum: " & employee(1) & "," 
        & "empFName: " & employee(2) & "," 
        & "empLName: " & employee(3) & ","
        & "empFullName: " & employee(4) & ","
        & "empExt: " & employee(5) & ","
        & "empTitle: " & employee(6) & "}"

End Function
%>

Currently, I'm getting the alert stating "No Data Received". What am I doing wrong?

  • 写回答

1条回答 默认 最新

  • 三生石@ 2017-03-20 20:56
    关注

    Instead of "return Employee", have you tried:

    response.write employee
    

    or maybe

    response.write employee.sAMAccountName
    

    Is this VB6? Not sure what libraries are available in classic asp, so you might have to manually write the data in JSON form... i.e...

    response.write "{ name: " & employee.sAMAccountName & "}"
    
    评论

报告相同问题?

悬赏问题

  • ¥15 三菱变频器模块怎么检测触发
  • ¥30 求一下解题思路,完全不懂。
  • ¥30 关于#硬件工程#的问题:求一下解题思路
  • ¥15 运筹学对偶单纯行法构造扩充问题
  • ¥20 XP系统的老电脑一开机就提示找不到rundll.exe,付费求解
  • ¥15 milvus查询出来的score怎么转换成0-1之间的相似性
  • ¥15 lvgl V9移植到linux开发板
  • ¥15 VB.net中在窗体中创建一个button控件来关闭窗体,但是提示错误,我该怎么办
  • ¥15 网上下载好的程序但是arduinoIDE编程报错,运行不了,哪里出错了,能具体给改一下吗
  • ¥15 Sharepoint JS开发 付费技术指导