This is my first attempt at this software and I'm having problems pulling data from a custom list I've created in sharePoint.

Here's what I have


var items;
    $(document).ready(function () {
         var context = SP.ClientContext.get_current();
         var list = context.get_web().get_lists().getByTitle('owlData');
         var camlQuery = SP.CamlQuery.createAllItemsQuery();
         items = list.getItems(camlQuery, 'owl');


        context.executeQueryAsync(Function.createDelegate(this, onListDataSucceeded), Function.createDelegate(this, onListDataFailed));  

    function onListDataSucceeded(sender, args) {

        var listItemEnumerator = items.getEnumerator();

        while (listItemEnumerator.moveNext()) {
            var oListItem = listItemEnumerator.get_current();



    function onListDataFailed(sender, args) {

        alert('List Data fetch failed. ' + args.get_message() + 'n' + args.get_stackTrace());


The custome list name is owlData (based on an online example) columns are: owl, date, action, location

I'm just trying to grab data from the owl column (a starting point)

Any help would be greatly appreciated!!

 $(document).ready(function() {
    ExecuteOrDelayUntilScriptLoaded(function getData(){
        //your code to get data from sharepoint list.  
    }, "sp.js");

load sp.js and then your code to retrieve list data



You may just need to specify your custom column in the request.




context.load(items, 'Include(owl)');
  • I've tried and the script doesn't run passed the changed statement. originally I've put an echo statement in the "onListDataSucceeded" function, right before the alert statement in the while loop and it echos out a statement. – user3299369 Sep 17 '14 at 2:46
  • Are you getting any errors in the Developer Tools Console? – Omar Stewey Sep 17 '14 at 3:03

To get the data from the custom SharePoint list you can use the lists.asmx webservice.

You can do something like this

  (function ($) {
//Get Elements from a custom list 
var ListName ="Custom ";    
var url = document.URL;
if (url.indexOf("https://") != -1) {
    var urllink = document.location.href.replace("https://", "");
    var prefix = "https://";
else {
    var urllink = document.location.href.replace("http://", "");
    var prefix = "http://";
var link;
if (urllink.indexOf("sites") != -1)
    link = (urllink.split("/"))[0] + "/" + (urllink.split("/"))[1] + "/" + (urllink.split("/"))[2];
    link = (urllink.split("/"))[0];
var soapEnv =
    "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
        <soapenv:Body> \
        <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
        <listName>"+ ListName + "</listName> \
        </GetListItems> \
        </soapenv:Body> \
    url: prefix + link + "/_vti_bin/lists.asmx",
    type: "POST",
    dataType: "xml",
    data: soapEnv,
    complete: processResult,
    contentType: "text/xml; charset=\"utf-8\""

//Process data from the list 
function processResult(xData, status) {      
    $(xData.responseXML).find("z\\:row, row").each(function () {

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.