- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我在服务器上托管了一个网页,例如 http://SVR1/path/index.html
,我想访问本地 SharePoint 站点中的一些列表项托管在另一台服务器上,例如 http://SVR2/sites/mySite/
。
我正在使用的(不受我控制的)SharePoint 的当前安装不允许部署 SharePoint 托管和提供商托管的应用程序,因此我正在尝试使用 SharePoint 跨域库来访问所需的列表项从一个纯粹的外部 HTML5/JS/CSS3 页面。作为用户,我对我的 SharePoint 网站中的列表具有完全访问权限,因此我想阅读其中的项目应该没有问题。
下面找到一个例子here ,我的页面如下:
<!doctype html>
<html>
<head>
<!-- Title -->
<title>Application Template</title>
<script language="javascript" type="text/javascript" src="js/jquery.js"></script>
<script language="javascript" type="text/javascript">
var hostweburl = "http://SVR2/sites/mySite";
var appweburl = "http://SVR1/path";
// Load the required SharePoint libraries
$(document).ready(function () {
$("#renderList").html("Requesting Lists...");
// resources are in URLs in the form:
// web_url/_layouts/15/resource
var scriptbase = hostweburl + "/_layouts/15";
// Load the js files and continue to the successHandler
$.getScript(scriptbase + "/SP.RequestExecutor.js", execCrossDomainRequest);
});
///////////////////////////////////////////////////////
// Function to prepare and issue the request to get
// SharePoint data
function execCrossDomainRequest() {
// executor: The RequestExecutor object
// Initialize the RequestExecutor with the app web URL.
var executor = new SP.RequestExecutor(appweburl);
// Issue the call against the host web.
// To get the title using REST we can hit the endpoint:
// hostweburl/_api/web/lists/getbytitle('listname')/items
// The response formats the data in the JSON format.
// The functions successHandler and errorHandler attend the
// sucess and error events respectively.
executor.executeAsync(
{
url: hostweburl + "/_api/web/lists",
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
success: successHandler,
error: errorHandler
}
);
}
///////////////////////////////////////////////////////
// Function to handle the success event.
// Prints the data to the page.
function successHandler(data) {
var jsonObject = JSON.parse(data.body);
var listsHTML = "";
var results = jsonObject.d.results;
for (var i = 0; i < results.length; i++) {
listsHTML = listsHTML +
"<p><h1>" + results[i].Title +
"</h1>" + results[i].Body +
"</p><hr>";
}
document.getElementById("renderList").innerHTML =
listsHTML;
}
///////////////////////////////////////////////////////
// Function to handle the error event.
// Prints the error message to the page.
function errorHandler(data, errorCode, errorMessage) {
document.getElementById("renderList").innerText =
"Could not complete cross-domain call: " + errorMessage;
}
</script>
</head>
<body>
<h1 id="Root Page" style="text-align:center;">This is the home page</h1>
<div id="renderList">Placeholder</div>
</body>
</html>
当我在浏览器中加载页面时,在 javascript 控制台中出现错误:“ Uncaught Error :无效的字段或参数 requestInfo.url。”。
我的印象是问题出在变量 appweburl
的内容中,在我发现的所有示例中,SharePoint 都将其作为 URL 中查询部分的一部分提供。但这意味着提供商托管的应用程序已部署在 SharePoint 中——这是我无法做到的——并且该应用程序正在调用其远程托管的对应应用程序。
所以问题是:是否可以在完全不属于 SharePoint 的页面中使用 SharePoint 跨域库,如果可以,我应该如何设置 hostweburl
、appweburl
也许还有其他访问 SharePoint 列表的东西?
提前致谢。
最佳答案
你提到的两个 URL,appwebUrl 和 hostwebUrl 确实是为在应用程序中使用而设计的,所以我认为你不应该使用跨域库。
如果您只是使用非应用程序方式连接怎么办?例如,您可以调用自定义 Web 服务(在共享点之外),它可以通过 CSOM 连接到您的 SP 站点,或者您可以直接在 javascript 中执行此操作。
关于javascript - 在简单网页中使用 SharePoint 2013 跨域库 : is it possible?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24182278/
这是我的本地域名 http://10.10.1.101/uxsurvey/profile/dashboard 在 Controller 中,我为用户列表设置了一个操作 redirect(control
要处理 Canonical URL,最佳做法是执行 301 重定向还是更好地为 www 和非 www 域使用相同的 IP 地址? 例如: 想要的规范 URL/域是 http://example.com
1 内网基础 内网/局域网(Local Area Network,LAN),是指在某一区域内有多台计算机互联而成的计算机组,组网范围通常在数千米以内。在局域网中,可以实现文件管理、应用软件共享、打印机
1 内网基础 内网/局域网(Local Area Network,LAN),是指在某一区域内有多台计算机互联而成的计算机组,组网范围通常在数千米以内。在局域网中,可以实现文件管理、应用软件共享、打印机
我想创建一个 weblogic 集群,其中有两个托管服务器,每个服务器在物理上独立的远程计算机上运行 根据weblogic文档 All Managed Servers in a cluster mus
我正在运行 grails 3.1.4,但在创建允许我将多个域对象绑定(bind)到其他几个域对象的模式时遇到了问题。作为我正在尝试做的一个例子: 我有三个类(class)。书籍、作者和阅读列表。 作者
我试图使用@count函数来根据它获取数据,但是在没有崩溃报告的情况下它以某种方式崩溃了。 这是代码 class PSMedia: Object { @objc dynamic var id
有谁知道是否有办法只输入字母字符而不输入数字?我想过这样的事情 CREATE DOMAIN countryDomain AS VARCHAR(100) CHECK( VALUE ??? );
我的代码: const checkoutUrl = 'https://example.com/checkout/*' window.onload = startup() function st
一些不是我编写的应用程序,也不是用 PHP 编写的,它为域 www.example.com 创建了一个 cookie。 我正在尝试替换该 cookie。所以在 PHP 中我做到了: setcookie
什么是 oauth 域?是否有任何免费的 oauth 服务?我可以将它用于 StackApps registration 吗? ?我在谷歌上搜索了很多,但找不到答案。 最佳答案 这是redirect_
自从 In October 2009, the Internet Corporation for Assigned Names and Numbers (ICANN) approved the cre
我使用 apache 作为我的应用程序 Web 服务器的代理,并希望即时更改与 sessionid cookie 关联的域名。 该cookie有一个与之关联的.company.com域,我想使用apa
我只想托管一个子域到cloudflare。我不想将主域名的域名服务器更改为他们的域名服务器。真的有可能吗? 最佳答案 是的,这是可能的,但是需要通过CloudFlare合作伙伴进行设置,或者您需要采用
When using socket in the UNIX domain, it is advisable to use path name for the directory directory m
想象两个共享一个域类的 Grails 应用程序。也许是 Book 域类。 一个应用程序被标识为数据的所有者,一个应用程序必须访问域数据。类似于亚马逊和亚马逊网络服务。 我想拥有的应用程序将使用普通的域
我有一个包含字段“URL”的表单。第一部分需要用户在文本框中填写。第二部分是预定义的,显示在文本框的右侧。 例如,用户在文本框中输入“test”。第二部分预定义为“.example.com”。因此,总
如果我要关闭并取消分配 azure 中的域 Controller ,从而生成新的 vm Generationid,我需要采取哪些步骤来恢复它? 最佳答案 what steps do I need to
我想尝试使用 Azure 作为托管提供商(我有一个域)。我读过那篇文章https://learn.microsoft.com/en-us/azure/app-service-web/web-sites
所以.... 我想知道是否有人可以在这方面协助我? 基本上,我已经创建了一个自托管的Docker容器,用作构建代理(Azure DevOps) 现在,我已经开始测试代理,并且由于我们的放置文件夹位于W
我是一名优秀的程序员,十分优秀!