Skip to content Skip to sidebar Skip to footer

How To Reload/rfresh A Div On Page Load?

I have a div block i want it to be automatically referrshed once or twice during when page is loading . How can refresh/reload the div once or twice using jquery or javascript?

Solution 1:

Where is it gonna reload from, what does the block look like ?

I would use jQuery ajax and reload content into the the div

but thats a much as I can say without having any idea about what the content is to look like , what the current content looks like or what you would receive back from an ajax call

hth

Solution 2:

I don't know exactly what you mean but try to look this example

$(function () {

setInterval(function () {
    $.ajax({
        type: "POST",
        cache: false,
        url: "Ajax/funk.cshtml",
        dataType: "text",
        success: function (data) {
            $('#divId').text(data);
                    alert('Load completed.');
        }
    });
}, 2000);
});

here: setInterval performs the action every 2000 milliseconds; jax/funk.cshtml - the file which will give you some text as a result(it may contain only @DateTime.Now for example in asp.net and will return time)

if you want renew the div only once you may use the same function for $(#somedive).onload(); or something like that.

Hope it will help!

Post a Comment for "How To Reload/rfresh A Div On Page Load?"