I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously.
I want that my div will automatically update in some interval time.
How can i do this.
I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously.
I want that my div will automatically update in some interval time.
How can i do this.
$(document).ready(function() {
var refreshId = setInterval(function()
{
$( #main ).fadeOut("slow").load( Default.aspx ).fadeIn("slow");
}, 50000);
});
Sorry for the bug. setTimeout is used as opposed to setInterval to accomodate for any delay that may occur in the AJAX request.
var to;
$(function() {
// initialize timer to update div every 5 seconds
to = setTimeout(updateDivContent, 5000);
});
function updateDivContent() {
// make your AJAX/LOAD request for the data here to populate div
$( #mydivcontainer ).empty().load( myAspFileToGrabExternalData.aspx , null, function() {
// reset the timer to grab the content in another 5 seconds
to = setTimeout(updateDivContent, 5000);
});
}
You can read up on jQuery s load method here.
You could use the setinterval function of jquery/javascript. For some information you can look at this tutorial: http://docs.jquery.com/Tutorials:Scroll_Up_Headline_Reader Or search the jquery document site for other references.
You need to use active polling (repeatedly checking the other site), which might earn you some hate from that site (as well as possibly have legal repercussions) unless you re the one who owns it. You might not want to use setInterval() to poll the other site as this could introduce race conditions if the site takes a bit to respond (i.e. if you re polling every 5 seconds, and the site takes 6 seconds to respond once, then 1 second to respond on the subsequent response, both of these will hit your page at the same time).
To borrow from cballou s post:
var to;
$(function() {
// initialize timer to update div every 5 seconds
to = setTimeout(updateDivContent, 5000);
});
function updateDivContent() {
// make your AJAX/LOAD request for the data here to populate div
$( #mydivcontainer ).load( myAspFileToGrabExternalData.aspx , null, function() {
// reset the timer to grab the content in another 5 seconds
to = setTimeout(updateDivContent, 5000);
});
}
Also, cballou s post has a bug where it would have queued a new interval each time it ran (so that after 3 iterations, you re fetching the page 3 times every 5 seconds, after 10 iterations, you re fetching it twice a second, etc).
In my webpages I have references to js and images as such: "../../Content/Images/"Filename" In my code if I reference a file as above, it doesnt work so i have to write: "c:/miscfiles/"filename" 1-...
I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...
Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...
I m looking for best practices here. Sorry. I know it s subjective, but there are a lot of smart people here, so there ought to be some "very good" ways of doing this. I have a custom object called ...
I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...
i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...
For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?
I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!