Hi All, I am new to REST. I am trying to get data from Announcement List using REST API oData call. I observed in the Fiddler that the REST call is being made on page refresh too. How can I avoid REST Call on page refresh?
<script>
$('#oDataAnnouncements').innerHtml ="";
jQuery.ajax({
url: "<WebSiteUrl>/_api/Web/Lists/getByTitle('Announcements')/items",
type: "GET",
headers: {"accept": "application/json;odata=verbose",
},
success: function(data){
jQuery.each(data.d.results, function(index, item){
jQuery('#oDataAnnouncements').append("<li>" + "<a href=" + "<WebsiteUrl>/Lists/Announcements/DispForm.aspx?ID=" + item.ID + ">" + item.Title + "</a></li>");
});
},
error: function(error){
alert(JSON.stringify(error));
}
});
</script>oDataAnnouncements is a div where I am putting the REST result. I know I can clear the content of the div to prevent displaying same data on page refresh. It's just that I want to know if I can avoid REST call repetedly.
Thanks,
Khushi
Khushi