如何使用oData和JavaScript从Sharepoint 2013中的列表检索数据

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何使用oData和JavaScript从Sharepoint 2013中的列表检索数据相关的知识,希望对你有一定的参考价值。

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. }

以上是关于如何使用oData和JavaScript从Sharepoint 2013中的列表检索数据的主要内容,如果未能解决你的问题,请参考以下文章