Category: Spserivces2014-09-21 04:03 233 people read Comments (0) favorite reports SharePoint 2013javascriptSPServices Open Source Library
Spservices-jquery Libraries for SharePoint Web Services is a JQuery-based open source library that can be downloaded to CodePlex: Click to open the link.
This library makes it easier for developers to invoke the Web services provided by SharePoint, and it is all client-side code that does not need to be installed on the server, lightweight and fast, while reducing server-side deployment time. Currently support for SharePoint 2007/2010/2013 is a good choice for SharePoint developers.
The method of integrating Spservices into a SharePoint project is simple, with the introduction of jquery and Spservices files on pages that need to use the library. First download jquery on the jquery website, the version used here is 1.11.1: Click to open the link. After the download we get the "jquery-1.11.1.min.js" file. Then download the spservices file: Click the open link, which is a zipped package that contains three files: License.txt, jquery. Spservices-2014.01.js and Jquery.spservices-2014.01.min.js, we use "jquery." Spservices-2014.01.min.js "This file.
With these two files, you can integrate them into a SharePoint project, using a more common approach as an example (VS2012 + SharePoint2013).
First copy the two files to the corresponding project folder under the Layouts folder:
Then add a applicaiton page "spservicestestpage.aspx":
Refer to these two files in the page (if it is a SharePoint 2007 or 2010 environment, you need to remove 15):
[HTML]View Plaincopy
- <asp:content id="Pagehead" contentplaceholderid="Placeholderadditionalpagehead" runat= "Server">
- <script src="/_layouts/15/sharepoint.testlab.spservices/jquery-1.11.1.min.js" type= "Text/javascript"></script>
- <script src="/_layouts/15/sharepoint.testlab.spservices/jquery. Spservices-2014.01.min.js " type=" Text/javascript "></script>
- <script type="Text/javascript">
- $ (document). Ready (function () {
- Alert ("JQuery is loaded!");
- Alert ($ (). Spservices.spgetcurrentsite ());
- });
- </Script>
- </asp:content>
In this case, because the JS file and the page file in the same folder, so the way to refer to JS can be simplified to:
[HTML]View Plaincopy
- <script src="jquery-1.11.1.min.js" type="Text/javascript"></script >
- <script src="jquery. Spservices-2014.01.min.js " type=" Text/javascript "></script>
The reference then adds a piece of code to test whether the load was successful. If the load is successful, then after deployment, access to this page will bring up two dialog boxes:
And
The contents of the second dialog box are passed "$ ()." Spservices.spgetcurrentsite () "method obtained, this method is provided by Spservices.
In fact, if you do not want to download the file, you can also use the CDN way, in the page reference, method is:
[HTML]View Plaincopy
- <asp:content id="Pagehead" contentplaceholderid="Placeholderadditionalpagehead" runat= "Server">
- <script src="//code.jquery.com/jquery-1.11.1.min.js" type="Text/javascript"> </Script>
- <script src="//cdnjs.cloudflare.com/ajax/libs/jquery. Spservices/2014.01/jquery. SPServices.min.js " type=" Text/javascript "></script>
- <script type="Text/javascript">
- $ (document). Ready (function () {
- Alert ("JQuery is loaded!");
- Alert ($ (). Spservices.spgetcurrentsite ());
- });
- </Script>
- </asp:content>
Of course there are other methods, such as putting files into a document library and then referencing, and so on, not for example, after the integration of spservices can begin to use its powerful features, these features will be introduced in succession.
Spservices one of the following: Add Spservices to a SharePoint project