user287844
user287844

Reputation: 29

How to automatically update a site with some other site contents.?

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

Upvotes: 1

Views: 219

Answers (2)

Phil Rykoff
Phil Rykoff

Reputation: 12087

$.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

Upvotes: 0

pdr
pdr

Reputation: 6440

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.

Upvotes: 1

Related Questions