Posted By

rumremix on 05/15/13


Tagged

javascript list sharepoint odata 2013


Versions (?)

How to retrieve data from a list in Sharepoint 2013 using oData and JavaScript


 / Published in: JavaScript
 

The following code fetches contents of each Title field from the list called "LandingMiddleLinks"

  1. function getTitles() {
  2.  
  3. // begin work to call across network
  4. var requestUri = _spPageContextInfo.webAbsoluteUrl +
  5. "/_api/Web/Lists/getByTitle('LandingMiddleLinks')/items";
  6.  
  7. // execute AJAX request
  8. $.ajax({
  9. url: requestUri,
  10. type: "GET",
  11. headers: { "ACCEPT": "application/json;odata=verbose" },
  12. success: function(data){
  13.  
  14. $.each(data.d.results, function(index) {
  15. console.log($(this).attr('Title'));
  16.  
  17. });
  18.  
  19. },
  20. error: function(){
  21. alert("Failed to get title");
  22. }
  23. });
  24. }

Report this snippet  

You need to login to post a comment.