在此之前我问一个问题如何通过网络浏览器显示地址簿here 。然后,我找到了一个可以运行并查找地址簿中所有信息的Agent。但我现在的问题是,我不知道如何显示对话框列表以便用户可以选择任何信息。
我的代理如下:
books = s.AddressBooks
foundflag = False
ForAll b In books
If b.FileName="names.nsf" Then
Call b.Open( "", "" )
Set view = b.GetView( "People" )
Call view.Refresh
foundflag = True
Exit ForAll
End If
End ForAll
If Not foundflag Then
returnVal = "NSF file not found."
GoTo endp
End If
count = 0
Set tmpdoc = view.GetFirstDocument
Do While Not tmpdoc Is Nothing
If tmpdoc.MailFile(0) <> "" _
And tmpdoc.MailAddress(0) = "" _
And tmpdoc.InternetAddress(0)<>"" Then
count = count + 1
tmpstr = tmpdoc.LastName(0)
If tmpstr="" Then tmpstr = tmpdoc.FirstName(0)
tmplist(count) = tmpstr & "|@|" & tmpdoc.InternetAddress(0)
End If
Set tmpdoc = view.GetNextDocument(tmpdoc)
Loop
If count=0 Then
returnVal = "No employee were found"
GoTo endp
End If
我有可以调用此代理的 jQuery,但我不知道如何在 HTML 中显示列表。我的 jQuery 如下:
$.post("http://server/pcspec.nsf/jsonEmpList?OpenAgent",
function(data, status) {
var arr = JSON.parse(data);
if (arr.status == "success") {
$(arr.items).each(function(i, item) {
$("#PUserID").append('<option value="' + item.mail + '">' + item.name + ' (' + item.mail + ')</option>');
});
} else {
alert(arr.message);
}
})
.fail(function(xhr, status, error) {
console.log("ERROR - " + xhr + " - " + status + " - " + error);
})
所以我的问题是,如何在网络浏览器中提示对话框列表以供用户进行选择。任何帮助将不胜感激。谢谢!
最佳答案
如果您问“如何将信息从代理返回到 jQuery”,答案就是 PRINT 语句。我在使用地址簿时遇到错误,因此我对公共(public)地址簿的名称进行了硬编码。但此代码片段将返回一个 JSON 对象。当然,您需要声明适当的变量并相应地设置服务器名称。
Set db = s.getDatabase("server/document","names.nsf",False)
If db Is nothing Then
print "ERROR: Names.nsf not found</br>"
exit sub
End If
Set view=db.getView("People")
Set tmpdoc = view.GetFirstDocument
Do While Not tmpdoc Is Nothing
If tmpdoc.MailFile(0) <> "" _
And tmpdoc.MailAddress(0) = "" _
And tmpdoc.InternetAddress(0)<>"" Then
tmpStr = ToJSON(tmpdoc)
Print tmpStr + "<br />"
End If
Set tmpdoc = view.GetNextDocument(tmpdoc)
Loop
结果:
{"value": "CN=John Doe/O=ACME", "text": "john.doe@acme.com"}
{"value": "CN=Jane Smith/O=ACME", "text": "jane.smith@acme.com"}
关于jquery - 如何在 Web 浏览器 (HTML) 中显示对话框列表,以便用户可以从 Lotus Notes 中的地址簿中选择信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57654379/