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.

1
  • the console is not defined in IE did you try removing the console logging Commented Feb 21, 2012 at 18:25

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

2 Comments

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?
Yes, as I said in my answer GET requests are cached by browsers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.