在 SharePoint Intranet 上处理跨域的最佳方法,无需服务器端、silverlight、DBC 等

发布于 2024-12-12 05:03:53 字数 165 浏览 9 评论 0 原文

我正在开发 Microsoft 内部 SharePoint 网站,并且需要从跨域 SharePoint 网站提取列表数据。

由于各种原因,我不想使用 Silverlight,并且目前无法实现业务数据连接。

有没有一种简单的方法可以使用 JavaScript 或类似的东西来完成此任务?

I'm working on a Microsoft internal SharePoint site, and I need to pull in List data from a cross domain SharePoint site.

I don't want to use Silverlight, for various reasons, and Business Data Connectivity is not possible right now.

Is there a simple way to use JavaScript or something like it to accomplish this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

傻比既视感 2024-12-19 05:03:53

简单?”不完全是。考虑到您的要求,特别是“无服务器端”,这是不可能的。

但是,如果您可以放弃该要求,则可以通过一些选项来启用跨域请求。

CORS

对于 针对 XMLHttpRequest 和 Microsoft 的 href="http://msdn.microsoft.com/en-us/library/cc288060(VS.85).aspx" rel="noreferrer">XDomainRequest。不过,这将要求远程服务器在响应中包含正确的标头,以允许您的源/域发出请求。

<% Response.AddHeader("Access-Control-Allow-Origin", "*") %>

JSONP

一个常见的选项是 JSONP,它将资源加载到

// <script src="http://other.dom/resource?callback=loadResource"></script>

loadResource( [ {"id": 1, "name": "foo"}, {"id": 2, "name": "bar"} ] );

服务器端代理

如果您发出请求的远程服务器无法(或不会)调整为支持跨域请求,那么您几乎只能在服务器上创建服务器端代理。

一般模式在 AjaxPatters.org 中进行了描述,并且可以找到许多 .NET 实现,包括 约翰Chapman 的跨域代理 项目。

"Simple?" Not exactly. Given your requirements, particularly "w/o server side," this isn't possible.

However, if you can forego that requirement, you have a few options for enabling cross-domain requests.

CORS

There's decent support for Cross-Origin Resource Sharing for XMLHttpRequest and Microsoft's XDomainRequest. Though, this will require that the remote server include the proper headers in the response to allow your origin/domain to make the request.

<% Response.AddHeader("Access-Control-Allow-Origin", "*") %>

JSONP

A common option is JSONP, which loads the resource in a <script> with a callback parameter with the name of a global function. Since JSON is based on JavaScript literals, this won't have the same browser-support issues, but the remote server will have to know how to construct the output and it's limited to GET requests.

// <script src="http://other.dom/resource?callback=loadResource"></script>

loadResource( [ {"id": 1, "name": "foo"}, {"id": 2, "name": "bar"} ] );

Server-side Proxy

If the remote server you're requesting from can't (or won't) be adjusted to support cross-domain requests, you're pretty much left with making a Server-Side Proxy on your server.

The general pattern is described at AjaxPatters.org and a number of .NET implementations can be found, including John Chapman's and the Cross-Domain Proxy project.

時窥 2024-12-19 05:03:53

您可以使用 JQuery 从 SharePoint 列表获取数据。 请参阅本文。

You can use JQuery to get data from a SharePoint list. See this article.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文