Oh what a process this was.
Generally I just need to get content from a list and use it on multiple pages, so there is consistency.
(realize it only works on Chrome and FF. Not IE11 yet) 😦
Step 1: Make a dummy list to work with, and add a few columns with a few rows of data
Standards > Requirements List
Step 2: Get the js files I need
Codeplex? Github? Where the… are these files?
Codeplex for SPServices
https://spservices.codeplex.com/releases/view/119578
and find the 1.11.0 version of JQuery corelibrary
https://code.jquery.com/jquery/
and add them to the project
Step 3: Check they work and watch for XHTTP Request warnings – I think the SPServices service uses deprecrated async functions
Adding jQuery+SPServices to a SharePoint Page: Step One, Always
http://stackoverflow.com/questions/28322636/synchronous-xmlhttprequest-warning-and-script
adding seems to work
$.ajaxPrefilter(function( options, original_Options, jqXHR ) {
options.async = true;
});
Step 4: Use these resources to get started
SPServices Stories #7 – Example Uses of SPServices, JavaScript and SharePoint
SPServices Stories #7 – Example Uses of SPServices, JavaScript and SharePoint
Step 5: Make sure you adding the weburl if you are using a subsite – you don’t need the vti_bin/list.asmx at the end of the url – if you have issues with grabbing the content and when you console.log your xdata you aren’t getting a responsexml to work with, double check the Network is bringing back the right content.
http://spservices.codeplex.com/wikipage?title=GetListItems
+ check the comments
(I tried :
http://stackoverflow.com/questions/11634206/sharepoint-getlistitems-not-returning-list-items
It looks like you need to access the root site. If, for some reason, you simply can’t use ECMAScript
clientContext = new SP.ClientContext();
var oWebsite = clientContext.get_site().get_rootWeb(); //this is the web object
var url = clientContext.get_site().Url; //this is the root url
var listServiceUrl = url + "/_vti_bin/lists.asmx";
You could always use location.host + "/_vti_bin/lists.asmx"
if that’s safe in your current setup.
But I ended up going with:
/js/jquery-1.11.0.min.js
/js/jquery.SPServices-2014.02.min.js
$(document).ready(function() {
$.ajaxPrefilter(function( options, original_Options, jqXHR ) {
options.async = true;
});
//console.log(“hellow12e14”);
/*clientContext = new SP.ClientContext();
var oWebsite = clientContext.get_site().get_rootWeb(); //this is the web object
var url = clientContext.get_site().Url; //this is the root url
var listServiceUrl = url + “/_vti_bin/lists.asmx”;
console.log(listServiceUrl );*/
$().SPServices({
operation: “GetListItems”,
async: false,
listName: “Requirements List”,
webURL: “http://enablingsolutions.bns/standards” ,
CAMLViewFields: “”,
CAMLRowLimit: 0,
completefunc: function (xData, Status) {
//console.log(xData.responseXML);
//console.log($(xData.responseXML).SPFilterNode(“z:row”));
//console.log($(xData.responseXML).SPFilterNode(“z:row”).length);
var liHtml = “”;
$(xData.responseXML).SPFilterNode(“z:row”).each(function() {
//console.log($(this).attr(“ows_Title”));
liHtml += “
” + $(this).attr(“ows_Title”) + “
“;
});
//console.log(liHtml);
$(“#tasksUL”).append(liHtml);
//console.log($(“#tasksUL”));
}
});
});
<ul id=”tasksUL”></ul>
Later I will try
http://spservices.codeplex.com/wikipage?title=%24%28%29.SPXmlToJson
Resources:
Good over view of functions
jQuery Library for SharePoint Web Services (SPServices) 2014.02 Released
Documentation
http://spservices.codeplex.com/documentation
http://spservices.codeplex.com/documentation#general-instructions
Using SPServices with CAMLQuery to get ListItems