Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7606445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:24:40+00:00 2026-05-31T00:24:40+00:00

I am loading a partial view into a page on a timer with jquery

  • 0

I am loading a partial view into a page on a timer with jquery Ajax. When the target div loads, initially the any images (in this case small thumbnail pngs) are not displayed, and then after a slight interval, they wink in. I would like them to either load immediately, or delay showing the div until the images have fully loaded. How should I go about doing this?

Partial I am loading:

<script type="text/javascript">
$(document).ready(function() {
    $('.Comment').waitForImages();
});

</script>

<h3>Comments</h3>
@foreach (var c in Model.Comments) {
    <div class="Comment">
        <img src='@string.Format("/ProfilePics/{0}_thumb.png", c.User.ID)' alt="@c.User.CN picture"/><strong>@c.User.CN</strong>    
        @Ajax.ActionLink("delete", "DeleteComment", "Item", new {commentID = c.ID, itemID = c.TaskItem.ID}, new AjaxOptions{HttpMethod = "POST", OnSuccess = "GetComments"})
        <br />
        <p>
            @c.Comment1</p>
    </div>
}

Div I am loading into (with partial prerendered so that it shows up on initial load):

<div id="Comments">
    @Html.Partial("GetComments", new GetCommentsModel(Model.Task.ID))
</div>

Javascript to load partial:

$(document).ready(function () {
    setInterval(GetComments, 15000);
});
function GetComments() {
    $('#Comments').load('/Item/GetComments', {
        id: '@Model.Task.ID'
    });

}

Controller action that is called by javascript:

[HttpPost]
[Authorize]
public ActionResult GetComments(int id) {
    return PartialView(new GetCommentsModel(id));
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T00:24:42+00:00Added an answer on May 31, 2026 at 12:24 am

    You could use the waitForImages plugin:

    function GetComments() {
        $.ajax({
            url: '@Url.Action("GetComments", "Item")',
            type: 'POST',
            data: { id: '@Model.Task.ID' },
            success: function(result) {
                $('#Comments').hide().html(result).waitForImages(function() {
                    $(this).show();
                });
            }
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am loading a partial view into a main view using ajax but struggling
I am updating a div with a partial view by using something like this:
I am using Loading a partial view in jquery.dialog as a reference in order
I am using @Darin Dimitrov's method explained in Loading a partial view in jquery.dialog
I'm loading a partial view with an AJAX call: public ActionResult LoadServerForm() { //data
This question relates to my previous question which asks about loading a page into
I am loading a partial view in the popup using following code: <div id=Mydiv
Loading images into Flex (size < 100kb) causes IE7 memory increase by a megabyte
After loading a PHP template (using jQuery's load function), this simple script won't make
How can I load a page or a partial view in the popup window

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.