Posts

Showing posts from September, 2019

Change Image on Every Page Load using Random Number Generator

How to Change Image on Every Page Load using Random Number Generator You can use the below code to change Image on Every Page Load JS Code: - var length; $(document).ready(function() { getFoldersTraining_dev(); });      function getFoldersTraining_dev() {          $.ajax({             url: _spPageContextInfo.webAbsoluteUrl + "/_api/Web/GetFolderByServerRelativeUrl('/teams/FMHub/Quotes_image_homepage')?$expand=Folders,Files",             type: "GET",             headers: { "Accept": "application/json;odata=verbose" }, // return data format             success: function (data) {               var html = "";                if(data.d.Files.results.length >0){                       length = data.d.Files.results.length;                        var x = Math.floor((Math.random() * (length  - 1)));                                                                                                                      

Save Data to SharePoint list using REST Api

How to Save Data to SharePoint list using REST Api You can use the below code to save data to SharePoint list using REST Api JS Code:- $(document).ready(function() {  $("#btn").click(function(){     CreateListItem();  }); }); function CreateListItem()    {      $.ajax         ({         url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('TestRestList')/items",         type: "POST",         data: JSON.stringify         ({             __metadata:             {                 type: "SP.Data.TestRestListListItem"             },             "Title": "Title"                  }),         headers:         {             "Accept": "application/json;odata=verbose",             "Content-Type": "application/json;odata=verbose",             "X-RequestDigest": $("#__REQUESTDIGEST").val(),             "X-HTTP-Method"

Get More than 5000 records from SharePoint list using Rest Api

How to Get More than 5000 records from SharePoint list using REST Api You can use the below JS code to get more than 5000 records from SharePoint list using REST Api JS Code:- var response = response || []; var url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('Cable_Status')/items?$Select=ID,LOB&$top=1000"; $(document).ready(function() {  GetListItems();   }); function GetListItems(){         return $.ajax({             url: url,             method: "GET",             headers: {                 "Accept": "application/json; odata=verbose"             },             async: false,             success: function(data){                 response = response.concat(data.d.results);                 if (data.d.__next) {                     url = data.d.__next;                     GetListItems();                 }                           var table = $("#MyTable");                 var