7

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?

Wesley
  • 5,381
  • 9
  • 42
  • 65

2 Answers2

10

"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.

Jonathan Lonowski
  • 121,453
  • 34
  • 200
  • 199
  • I'll give JSONP a try and let you know. Server side simply isn't allowed by the IT team that governs the sites. Silverlight can do this, but it's much slower and is really a sub-optimal experience for the end user. – Wesley Oct 24 '11 at 19:38
  • This is one of the best, concise descriptions I have seen in one place. Thank you! – Jess Jul 11 '13 at 16:46
  • should i add the header in default page of the site? – Vignesh Subramanian Apr 21 '15 at 08:18
-2

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

Ken
  • 734
  • 2
  • 8
  • 22