Reputation: 1
I'm developing a web application externally from sharepoint online 2010. As part of the application I would like to allow users to access documents from a document library. Ideally users would click on an option, this would query the library for documents, and return a JSON object for each object satisfying the query for display as links in a webpage.
I've been looking for a way to do this in a website hosted externally from sharepoint 2010, but I have been unable to find resources describing how to load the ECMA script API and connect to a sharepoint site. Does anyone know where I can find this information?
Thank you for your help!
Upvotes: 0
Views: 6960
Reputation: 1206
You have several ways to achieve this. The out of the box option would be using queries (from server code or ajax) your list SVC. In case you don't know, all lists have an associated service to pull information.
There is a wonderful js library at codeplex, spservices, that helps you to query your sharepoint. With this list you could do something like this (sample code taken from codeplex samples)
<script language="javascript" type="text/javascript">
$(document).ready(function() {
$().SPServices({
operation: "GetListItems",
async: false,
listName: "Announcements",
CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function() {
var liHtml = "<li>" + $(this).attr("ows_Title") + "</li>";
$("#tasksUL").append(liHtml);
});
}
});
});
</script>
More information at http://spservices.codeplex.com/wikipage?title=GetListItems? Keep in mind if the list has security restrictions you will run into pretty "interesting" authetication issues as you are running this calls outside sharepoint and it will not know who the hell is making the calls. So, just as a suggestion, consider running your pages under sharepoint.
Upvotes: 2