Deepak Upadhya

Deepak Upadhya

  • NA
  • 34
  • 2.5k

How to Display SharePoint Online365 List Items on non spsite

Sep 21 2018 8:04 AM
How to Display SharePoint Online 365 List Items on non - share point site , you can say a site built using html. how we can connect? I have tried using simple html page and REST API. its giving error as "Access Denied". Looks like I am missing something or i am using wrong methods. Please help
 
below is my code :
  1. <html>  
  2. <head>  
  3. <script src="/jquery.min.js"></script>  
  4. <script>  
  5. $(document).ready(function() {  
  6. function executesearch(){  
  7. var siteurl = "https://abc.com/sites/space2/xyz/_api/lists/getbytitle('Pages')/Items";  
  8. $.ajax({  
  9. url: siteurl,  
  10. method: "GET",  
  11. headers: { "Accept""application/json; odata=verbose" },  
  12. success: function (data) {  
  13. if (data.d.results.length > 0 ) {  
  14. alert(data);  
  15. }  
  16. },  
  17. error: function (data) {  
  18. alert("Error: "+ siteurl);  
  19. }  
  20. });  
  21. }  
  22. $("#search-button").off().click(function(e) {  
  23. executesearch();  
  24. });  
  25. });  
  26. </script>  
  27. </head>  
  28. <body>  
  29. <div class="test">  
  30. <button class="btnsearch" id="search-button">  
  31. FIND CONTENT</button>  
  32. </div></body>  
  33. </html>  

Answers (5)