Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

How to avoid REST call on page refresh

$
0
0

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


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>