Export Sharepoint list to json using jquery

Asked

Viewed 111 times

1

I’m using the sharepoint and would like to know if there is any way to export the list from Sharepoint to json, that is, to make a ajax

  • Hello it is possible yes, you can use the Rest API itself or the Client Object Model to do this with javascript. See this link for more information: https://github.com/andrei-markeev/camljs. If you have already assembled something publish your code

1 answer

0

Hello You should create an HTML like this:

<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="RESTGetListItems.js"></script>
<div id="divListItems"></div>

And Javascript this way:

$(function () {
retrieveListItems();});

function retrieveListItems() {var siteUrl = _spPageContextInfo.webAbsoluteUrl;
var fullUrl = siteUrl + "/_api/web/lists/GetByTitle('Demo List')/items?$filter=Id ge 4";
$.ajax({
    url: fullUrl,
    type: "GET",
    headers: {
        "accept": "application/json;odata=verbose",
        "content-type": "application/json;odata=verbose",
    },
    success: onQuerySucceeded,
    error: onQueryFailed
});}

function onQuerySucceeded(data) {
var listItemInfo = '';

$.each(data.d.results, function (key, value) {
    listItemInfo += '<strong>ID: </strong> ' + value.Id +
        ' <strong>Title:</strong> ' + value.Title +
        '<br />';
});

$("#divListItems").html(listItemInfo);}



function onQueryFailed(sender, args) {
alert('Error!');}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.