0

I know this question has probably been answered over 200 times and I have surfed stackoverflow for the last 2 hours now trying every solution possible so I guess I will fire away here..

I have a partial view that looks like this.

@using DatabaseEntities;
@using NJNightLifePortal.Models;
@model NJNightLifePortal.Models.StatisticsViewModel
@foreach (var item in Model.RecentlyLiked)
{
<div class="resultbox1">
    @Html.ActionLink(item.Username, "profile", "account", new { id = item.Username }, null)
    has recently liked @Html.ActionLink(item.VenueName, "venueprofile", "venue", new { id = item.VenueId, albumId = Utils.GetVenueDefaultAlbumIdByVenueId(item.VenueId) })
</div>    
}

I am then calling a jqery ajax function on this via setTimeout as shown below.

 $(function () {
        setTimeout(
            function () {
                setInterval(RefreshStats, 2000);
                RefreshStats();
            }, 3000);

        function RefreshStats() {
            $.get('@Url.Action("LatestActivities", "Statistics")', function (data, status) {
                console.log(data);
                $('.resultbox1').html(data);
            });

        }

I have tried $.load, $.ajax as well.. I have also tried document.getElementById(element).innerHTML = data; and I have still got the same results. Every single one of the aforementioned conventions work great in firefox and chrome but no matter what I do with IE it either ends up refreshing with blank results or recreating a totally new div that is not even returned by the partial view.

Please ask or request whatever I am trying to figure this out and would love to have a solid fix and not a hack fix unless it's neccessary. All I am trying to do is retrieve some db results and display them as they are formatted in the partial view back into the div called resultbox1.

Thank you so much in advance.

nkm
  • 5,616
  • 2
  • 22
  • 36
jhartzell
  • 273
  • 1
  • 3
  • 12

1 Answers1

1

Maybe IE caches the responses (which is normal for GET requests, it's just that IE is a little more aggressive in that respect). Things to try:

  • decorate your LatestActivities controller action with a custom [NoCache] attribute
  • use a POST request: replace your $.get with $.post
  • replace your $.get with $.ajax and set the cache: false option
Community
  • 1
  • 1
Darin Dimitrov
  • 960,118
  • 257
  • 3,196
  • 2,876
  • Darin, Thanks a lot for your help. I tried your later two suggestions. I changed my ajax call from $.get to $.post and everything started working correctly across all browsers.. Is there a reason for this? – jhartzell Feb 22 '12 at 12:37
  • Yes, as I said in my answer GET requests are cached by browsers. – Darin Dimitrov Feb 22 '12 at 12:42