Spservices one of the following: Add Spservices to a SharePoint project

Source: Internet
Author: User

  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
  1. <asp:content id="Pagehead" contentplaceholderid="Placeholderadditionalpagehead" runat= "Server">
  2. <script src="/_layouts/15/sharepoint.testlab.spservices/jquery-1.11.1.min.js" type= "Text/javascript"></script>
  3. <script src="/_layouts/15/sharepoint.testlab.spservices/jquery. Spservices-2014.01.min.js " type=" Text/javascript "></script>
  4. <script type="Text/javascript">
  5. $ (document). Ready (function () {
  6. Alert ("JQuery is loaded!");
  7. Alert ($ (). Spservices.spgetcurrentsite ());
  8. });
  9. </Script>
  10. </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
    1. <script src="jquery-1.11.1.min.js" type="Text/javascript"></script >
    2. <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
  1. <asp:content id="Pagehead" contentplaceholderid="Placeholderadditionalpagehead" runat= "Server">
  2. <script src="//code.jquery.com/jquery-1.11.1.min.js" type="Text/javascript"> </Script>
  3. <script src="//cdnjs.cloudflare.com/ajax/libs/jquery. Spservices/2014.01/jquery. SPServices.min.js " type=" Text/javascript "></script>
  4. <script type="Text/javascript">
  5. $ (document). Ready (function () {
  6. Alert ("JQuery is loaded!");
  7. Alert ($ (). Spservices.spgetcurrentsite ());
  8. });
  9. </Script>
  10. </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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.