Skip to content

Instantly share code, notes, and snippets.

@dennythecoder
Created November 8, 2019 01:59
Show Gist options
  • Save dennythecoder/1877407f042de235b13453611cde22ff to your computer and use it in GitHub Desktop.
Save dennythecoder/1877407f042de235b13453611cde22ff to your computer and use it in GitHub Desktop.
SP 2010 Get List example
function getList(name, cb){
var serviceUrl = 'http://yoursite/_vti_bin/listdata.svc/';
var xhr = new XMLHttpRequest();
xhr.open('GET', serviceUrl + name);
xhr.setRequestHeader('accept', 'application/json;odata=verbose');
xhr.onreadystatechange = function(){
if(this.readyState === 4){
var obj = JSON.parse(this.response);
cb(obj.d.results);
}
}
xhr.send();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment