views:

54

answers:

2

How to update a site with some other site contents that is getting refreshed often (may be twice in a minute)?

A: 

$.load() is your friend. The following JQuery-function call will replace the current value of element (e.g. div) with the id "result" with the content of page "ajax/test.html".

$('#result').load('ajax/test.html');

or with an additional success handler:

$('#result').load('ajax/test.html', function() {
  alert('Load was performed.');
});

if you would like to call one of these function every n seconds, use the following code:

setInterval(function() {
  // wrap one of the above calls
}, <n>000);

edit: for a cross-domain-solution, you can write a proxy page on your site which, upon call, loads the content of the 'other site' and echoes it.

Snippet available here: http://www.daniweb.com/code/snippet216729.html

henchman
This will only work if you reference a page within your site, not a different site though.
Russell Giddings
added comment for a cross-domain solution (one site on domain a getting content of another site on domain b), so now it works in such a szenario, too! :-)
henchman
+1  A: 

What you're doing is called scraping a website. Try googling on that. Pay particular attention to the laws around it. If you're benefiting the company you're scraping, they'll probably help you; if you're not, they'll probably sue you.

pdr
+1, screen scraping. There might be a possibility you can find similar providers of the information you need that expose web services.
JL