Getting Sharepoint 2013 List Items Using jQuery

Step 1 : Create one list and add items in it .

Create

Step 2 : Download jQuery Reference file from the link ,given below (you can select version as per your requirement).

jquery

Step 3: Open Visual Studio, create SharePoint new project and add Application page in it. Add downloaded jQuery file reference in it and write the following code in it .

Code

  1. <script type="text/javascript">  
  2.     $.ajax({  
  3.         url: "SiteUrl/_api/web/lists/getbytitle('ListName')/items?$Select=Title"// ur site url goes here  
  4.         type: "GET",  
  5.         headers: {  
  6.             "Accept""application/json;odata=verbose"  
  7.         },  
  8.         success: function(data, textStatus, xhr) {  
  9.             $.each(data.d.results, function(index, item) {  
  10.                 alert("The items in list are : " + item.Title);  
  11.             })  
  12.         },  
  13.         error: function r(xhr, textStatus, errorThrown) {  
  14.             alert("error:" + JSON.stringify(xhr));  
  15.         }  
  16.     });  
code

Step 4 :
Deploy the solution and see the result.

output

output

output

 

Ebook Download
View all
Learn
View all