在 SharePoint Intranet 上处理跨域的最佳方法,无需服务器端、silverlight、DBC 等
我正在开发 Microsoft 内部 SharePoint 网站,并且需要从跨域 SharePoint 网站提取列表数据。
由于各种原因,我不想使用 Silverlight,并且目前无法实现业务数据连接。
有没有一种简单的方法可以使用 JavaScript 或类似的东西来完成此任务?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
“简单?”不完全是。考虑到您的要求,特别是“无服务器端”,这是不可能的。
但是,如果您可以放弃该要求,则可以通过一些选项来启用跨域请求。
CORS
对于 针对
XMLHttpRequest
和 Microsoft 的 href="http://msdn.microsoft.com/en-us/library/cc288060(VS.85).aspx" rel="noreferrer">XDomainRequest
。不过,这将要求远程服务器在响应中包含正确的标头,以允许您的源/域发出请求。JSONP
一个常见的选项是 JSONP,它将资源加载到
服务器端代理
如果您发出请求的远程服务器无法(或不会)调整为支持跨域请求,那么您几乎只能在服务器上创建服务器端代理。
一般模式在 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'sXDomainRequest
. Though, this will require that the remote server include the proper headers in the response to allow your origin/domain to make the request.JSONP
A common option is JSONP, which loads the resource in a
<script>
with acallback
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 toGET
requests.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.
您可以使用 JQuery 从 SharePoint 列表获取数据。 请参阅本文。
You can use JQuery to get data from a SharePoint list. See this article.